I'm trying to deal with the problem of the area inside the ng-repeat loop - I looked through a few questions, but I was not able to get my code to work.
Controller Code:
function Ctrl($scope) { $scope.lines = [{text: 'res1'}, {text:'res2'}]; }
View:
<div ng-app> <div ng-controller="Ctrl"> <div ng-repeat="line in lines"> <div class="preview">{{text}}{{$index}}</div> </div> <div ng-repeat="line in lines"> <-- typing here should auto update it preview above --> <input value="{{line.text}}" ng-model="text{{$index}}"/> </div> </div> </div>
Here's the script: http://jsfiddle.net/cyberwombat/zqTah/
Basically, I have an object (this is a pilot generator) that contains several lines of text. Each line of text can be changed by the user (text, font, size, color, etc.), and I want to create a preview for him. The above example only shows an input field for entering text, and I would like this to automatically or somehow update the preview, but there will be many other controls.
I'm also not sure if I got the code for the loop index - is this the best way to create the ng model name inside the loop?
javascript angularjs
cyberwombat Jan 19 '13 at 4:08 2013-01-19 04:08
source share