After adding a new element to my object array, I'm having trouble getting it to reflect in the view. Can anyone offer assistance?
This is my first time working with AngularJS.
My Code
Javascript
var App = angular.module('App', []);
App.controller('TestCTRL', function ($scope) {
$scope.addToList = function() {
$scope.listitems = [];
var f = this.data.firstName;
var l = this.data.lastName;
var i = this.data.id;
var newItem = new function() {
this.firstName = f;
this.lastName = l;
this.id = i;
}
$scope.listitems.push({newItem});
$scope.$apply();
}
});
HTML
<div ng-controller="TestCTRL">
....
.....
....
<div ng-repeat="item in listitems">
<div>{{item.firstName}}</div>
</div>
</div>