2014-09-28 49 views
0

我似乎找到了一個解決方案,因爲它不是輸出形式的數據角形式屏幕

var app = angular.module('myApp', []); 

app.controller('mainController', ['$scope', function($scope) { 

    $scope.update = function(person){ 
     $scope.club = angular.copy($scope.person); 
    }; 

}]); 

小提琴: http://jsfiddle.net/2ykgjmfs/

+0

如果我們可以看到表單邏輯 – Pytth 2014-09-28 16:56:31

回答

0
var app = angular.module('myApp', []); 

app.controller('mainController', ['$scope', function($scope) { 

    $scope.person = {}; 
    $scope.club = []; 

    $scope.update = function(person){ 
     $scope.club.push(person); 
     $scope.person = {}; // clear out the form 
    }; 
}]); 

或只是......

ng-click="update()" 

and

$scope.update = function() { 
    // you don't need to pass the person because it's on the $scope 
    $scope.club.push($scope.person); 
    $scope.person = {}; // clear out the form 
};