当点击按钮时,让对象c=a+b,也就是合并对象,怎么破,求解答
<body ng-app="myApp">
<div ng-controller="myCtrl">
<input type="text" ng-model="a[index]"><br><br>
<input type="text" ng-model="b[index]">
<div>
<button type="button" ng-click="btn1()">btn1</button>
<button type="button" ng-click="btn2()">btn2</button>
</div>
</div>
</body>
angular.module('myApp', [])
.controller('myCtrl', ['$scope', function($scope,$log) {
$scope.a = {};
$scope.b = {};
$scope.c = ?;
$scope.index = 1;
$scope.btn1 = function(){
$scope.index = 1;
}
$scope.btn2 = function() {
$scope.index = 2;
};
}]);
相关分类