How to set a value to scope object.object in angularjs -


how set value , value in form of $scope.object1.object = "some data";

in html , js if set data work.

<select ng-model="mycolor" ng-options="color.name color in colors">   $scope.colors = [           {name:'black', shade:'dark'},           {name:'white', shade:'light'},           {name:'red', shade:'dark'},           {name:'blue', shade:'dark'},           {name:'yellow', shade:'light'}         ]; 

but want these

 <select ng-model="mycolor" ng-options="color.name color in test.colors">    $scope.test.colors = [           {name:'black', shade:'dark'},           {name:'white', shade:'light'},           {name:'red', shade:'dark'},           {name:'blue', shade:'dark'},           {name:'yellow', shade:'light'}         ]; 

see example in plunker demo

see plunkr

angular.module('selectexample', [])   .controller('examplecontroller', ['$scope', function($scope) {     // add next line     $scope.test = {}     $scope.test.colors = [       {name:'black', shade:'dark'},       {name:'white', shade:'light'},       {name:'red', shade:'dark'},       {name:'blue', shade:'dark'},       {name:'yellow', shade:'light'}     ];     $scope.mycolor = $scope.test.colors[2]; // red   }]); 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -