angularjs - What magic does ngModel use that modifying the scope directly does not? -
Learning Angulius for the moment, and I'm confused about how I can accomplish a task because of me completely Do not understand NgModel is doing it.
If I have instructions with two scope variables:
// An array of all my objects $ scope.allMyObjects // Currently the selected object array $ radius Selected object and html
& lt; Span & gt; {{SelectedObject.name}} & lt; / Span & gt; & Lt; Select ID = "Select" ng-model = "selected object" ng-options = "all objects in object" & gt; & Lt; / Select & gt; All this works perfectly, when I select from selecting an object, it updates the selected object on the scope and therefore the current The name of the selected object is displayed in However, I do not want a select box, instead I want a list of all items with an editable name field, with a select button that I can use to select the specified object , So I came up with the following:
& lt; Div ng-repeat = "objects in all objects" & gt; & Lt; Input class = "object-name" ng-model = "object.name" & gt; & Lt; An NG-Click = "Load Object (Object)" & gt; Load & lt; / A & gt; & Lt; / Div & gt; and on the scope loadObject () function: function loadObject (object) {$ scope.selectedObject = object; } However, it does not work, I assumed it was basically what was enngode behind the scenes, but it is clearly confused. Does anyone have to give some light or do I have to provide better solution for what I want to achieve?
please see here:
instead of "sc.name"
& quot; Div ng-repeat = "Object in all objects" name "ng-model =" object.name "Use & gt; & lt; input class =" object-name "ng-model =" object.name "& gt; >
Comments
Post a Comment