猿问

angularjs 对象合并

当点击按钮时,让对象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;
    };
    
}]);

小轩1986
浏览 1885回答 1
1回答
随时随地看视频慕课网APP

相关分类

AngularJS
我要回答