javascript - How to push a constant value -


i trying push value in array. array on scope. seems pretty simple operation. missing something?

(function () {     angular.module('myapp', [])        .constant('datatypes', [{ 'key': 'number', 'value': 1 }, { 'key': 'text', 'value': 2 }, { 'key': 'datetime', 'value': 3 }])        .constant('blankcolumn', { 'name': 'column', 'type': 2, 'description': '' })        .controller('columnscontroller', ['$scope', 'datatypes', 'blankcolumn', columnscontroller])       function columnscontroller($scope, datatypes, blankcolumn) {         $scope.model = {};          $scope.model.addcolumn = function () {             if (!$scope.model.columns) {                 $scope.model.columns = [];             }              $scope.model.columns.push(blankcolumn);  //error here. first index rendered others not         };     } })(); 

when push blankcolumn columns property pupulated first index rendered. columns propoerty being displayed in ng-repeater.

use track $index in case repeat duplicate entry in array.

here plunker


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -