Angularjs using once the value from ng-repeat

I have following ng-repeat

<div ng-repeat="page in pages">
<input type="text" ng-model="page.name"
</div>

Basically this will show page.name multiple times for same name. Problem is my data being returned is in collection so I cant just use the name property. Can you please tell me how can i just show page.name only once.

Answers


I'd still say your better off pulling this data into it's own property but here's a lazy way to achieve the goal:

HTML

<!DOCTYPE html>
<html>
  <head>
    <script data-require="angular.js@*" data-semver="1.2.14" src="http://code.angularjs.org/1.2.14/angular.js"></script>
    <script src="script.js"></script>
  </head>
  <body ng-app="myApp" ng-controller="MyCtrl">
    <input type="text" ng-model="pages[0].name"/>
  </body>
</html>

JS

// Code goes here

angular.module("myApp", []).controller("MyCtrl", function($scope){
  $scope.pages = [{name:"Page1"},{name:"Page2"}];
})

Plunkr: http://plnkr.co/edit/UmRSVek3psKoklxVKBfI?p=preview


Need Your Help

Ajax tab not executing script

jquery html ajax tabs

I am using JQuery UI tabs to load content through Ajax. I have two tabs that should load html content and execute a script to hide or show some elements in the loaded content. I was running into an...