javascript - How to display output of function from ng-init in div? -
trivial for most
Well then I have this div I would have been set on the right to bind some values after ng-if and stated after nG-Int .. being called my nG-Int on this point but the message is not binding. I can have the wrong tags but what do you mean by me .. I want the function to be called after my statement is true.
& lt; Div ng-repeat = "field fieldData" in the model & gt; & Lt; Button class = "btn-xs" ng-show = "! ILock (field.id)" ng-click = "openfield (field)" & gt; & Lt; / Button & gt; Edit & lt; Div ng-if = "isLocked (field.Id)" ng-init = "msg = getLockMessage (field.Id)" ng-bind = "msg" & gt; & Lt; / Div & gt; & Lt; / Div & gt;
See this plunker:
There is a little example based on your HTML, and it works; Elements change the element changes inside the parent, because the same variable is changed if too many field data exists.
JS:
var app = angular Module ('plunker', []); App.controller ( 'MainCtrl', function ($ scope) {$ scope.model = {fieldData: [{id: 123, Lock wrong,}]} $ $ scope.isLocked = function (element) {return element.locked ;} $ Scope.openField = Function (element) {element.locked = true;} $ scope.getLockMessage = function (element) {return "message" + element.Id}});
and html:
& lt; Div ng-repeat = "field.fieldData" & gt; & Lt; Button class = "btn-xs" ng-show = "! ILock (area)" ng-click = "openfield (field)" & gt; & Lt; / Button & gt; Edit & lt; Div ng-if = "isLocked (region)" ng-init = "field.msg = getLockMessage (field)" ng-bind = "field.ms" & gt; & Lt; / Div & gt; & Lt; / Div & gt;
Comments
Post a Comment