How to make a double click editable table in AngularJS way?

前端 未结 2 585
不知归路
不知归路 2020-12-15 10:59

Without DOM manipulation, how to make an editable table cell with double click?

I am trying to make it there http://jsfiddle.net/bobintornado/F7K63/35/?

my

2条回答
  •  别那么骄傲
    2020-12-15 11:24

    I updated the fiddle. Is this how you want to do it?

    HTML

    
        
            {{item.name}}
            
        
    
    

    JS

    $scope.items = [{name: "item #1", editing: false}, 
                    {name: "item #2", editing: false}, 
                    {name: "item #3", editing: false}];
    
    $scope.editItem = function (item) {
        item.editing = true;
    }
    
    $scope.doneEditing = function (item) {
        item.editing = false;
        //dong some background ajax calling for persistence...
    };
    

    However you should probably create a directive containing the editable row. And implement the autofocus there, when you dblclick on an item.

提交回复
热议问题