angularjs - Preserve scope values while moving template in ng-repeat -


I have two collections that are binded to the UI that are ng-repeat

In this I have ng-include = "template.html"

  & lt; Div & gt; Have included. & Lt; Div ng-repeat = "item 1 in item 1" & gt; & Lt; Ng- included src = "item.template" & gt; & Lt; / Ng-include & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt; Div ng-repeat = "item in item 2" & gt; & Lt; Ng- included src = "item.template" & gt; & Lt; / Ng-include & gt; & Lt; / Div & gt; & Lt; / Div & gt;  

and my templates are given below

   & Lt; / Div & gt; & Lt; / Script & gt;  

and my controller is like the following

  myApp.controller ("MainCtrl", function ($ scope) {$ scope.items1 = [] ; $ Scope.items2 = []; var item1 = {Name: "1", Template: "Template 1.html"}; var item2 = {Name: "2", Template: "template2.html"} var item3 = {Name: "3", Template: "Template 3.html"} $ scope.itm1push (item1); $ scope.itm1push (item2); $ scope.itm1push (item 3); $ Scope.reiditem = function () {$ scope.items2.push ($ scope.items1.pop ());}});  

And another controller referenced in the template is like the following

  myApp.controller ("controller 1", function ($ scope) {console.log ("Start"); $ scope.a = 'hello';});  

Now when I move objects from one collection to another, (I enter some value in the input box) I want to preserve the area variable of the controller when it rotates Time scope value should be stored in the same place), but angular always creates a new opportunity and destroys the previous radius values ​​when the template is again added to the ng-repeat.

But I do not want this and should maintain the same template while roaming around the collection, so how can I do this?

In the above belt I want the same scope of the variable if I change something in the input box and move it to another collection

>

As someone has commented something like a work

  var item1 = {name: "1", hoo : 'Asdfasdf', template: "template1.html"}; Var item 2 = {name: "2", hoo: 'adddddddsdfasdf', template: "template2.html"}; Var Item 3 = {Name: "3", hoo: 'asdfasdffffffffff', Template: "template3.html"};  

and

  & lt; Script type = "text / ng-template" id = "template2.html" & gt; & Lt; Div ng-controller = "controller2" & gt; & Lt; Input ng-model = "item.hoo" /> & Lt; / Div & gt; & Lt; / Script & gt;  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -