我不知道我做得不对,我发现很难将新变量推入范围
$scope.usermsg= [
{ name: 'John', age: 25 },
{ name: 'Barry', age: 43 },
{ name: 'Kim', age: 26 },
{ name: 'masa',age: '14'},
{ name: 'Fritz', age: 19 }];
$scope.send=function(){
$scope.varb =({"name": 'masa222',"age": '1422'})
$scope.usermsg.push=($scope.varb)
}
HTML
<div ng-repeat="rows in usermsg">
<li>{{ rows.name + ' - ' + (rows.age)}}</li>
</div>
<button class="button button-icon icon ion-ios-paperplane footer-btn" type="submit" ng-click="send()">
</button>
答案 0 :(得分:0)
请检查
UserRepeatedPasswordType
// Code goes here
var myApp = angular.module("myApp", []);
myApp.controller("myController", function($scope){
$scope.usermsg= [
{ name: 'John', age: 25 },
{ name: 'Barry', age: 43 },
{ name: 'Kim', age: 26 },
{ name: 'masa',age: '14'},
{ name: 'Fritz', age: 19 }];
$scope.send = function()
{
var item = {name:'Ajay', age : 27};
var items = $scope.usermsg;
items.push(item);
return items
}
});