AngularJs Simple Edit -


i following tutorial basic understanding of angularjs. in case edit link not load object properties textbox. please let me know doing wrong here code , fiddle

<body> <div class="scope" data-ng-app="mymodule" data-ng-controller="mycontroller">     <h3>angularjs filter data sample </h3>     <br />     name:<br />      <input type="text" data-ng-model="name" /><br />     <input type="text" data-ng-model="position" /><br />     <button data-ng-click="addfriend()"> add friend</button>     <br />     <input type="text" data-ng-model="namesearch" /><br />     <ul>         <li class="li" data-ng-repeat="element in friendlist | filter:namesearch | orderby:'name'">             <strong> [{{$index + 1}}] {{ element.name | uppercase}} working {{ element.position}}  </strong>             [ <a href="#" ng-click="clearuser(element)">clear</a>             | <a href="#" ng-click="removeuser(element)">x</a>             | <a href="#" ng-click="edituser(1)">edit</a>             ]         </li>     </ul> </div> </body> 

and js code

var mymodule = angular.module('mymodule', []) mymodule.controller('mycontroller', ['$scope', function ($scope) {     $scope.friendlist =         [{ name: 'zia', position: 'am' }, { name: 'zia1', position: 'pm' }, { name: 'zia2', position: 'gm' }         ];      $scope.edituser = function (id) {          (i in $scope.friendlist) {             if ($scope.friendlist[i].name == 'zia') {                  $scope.newfriend = angular.copy($scope.friendlist[i]);             }         }     } }]); 

fiddle

and want know significance of class="scope" in first div

does solve question? http://jsfiddle.net/3hv7y369/

in inputs need newfriend.name , newfriend.position show copied values. finished edituser() function work every user.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -