angular ngmodel - How to get the name of model passed into the function in AngularJS? -


I have a scenario where I need to know the value and name of the model passed in the ceremony < P> I tried the following

  $ scope.rad = 'fff'; app.directive ('kmRadio', function () {return {restrict: 'e', ​​compiled: function (element, ethers) {var model = {l: '}}; model.l = attrs.km model; var str1 = "n in"; var str2 = attrs.kmOption; var repeat = str1.concat (str2); var htmlText = '
gt; & lt; div ng-switch on = "format" & gt; '+' & Lt; div ng "+ +" & lt; div class = "floatLeft"> '+ +' + attrs.title + '+' & lt; / div & gt; '+' & lt ; Ul & gt; '+' & lt; li class = "rowlight" ng-repeat = "'+ repeat +'" & gt; & amp; nbsp; {{n}} & lt; input type = "radio" Ng-model = "'++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++ attrs.kmModel + ' }} '+ + Attrs.kmModel + +' + + Model. L + "" & # 39; + & lt; / div> & # 39; + '& lt; div ng- switch - When = "kimono observation"> '+' & lt; div & gt; '+ attrs.title +' & lt; input type = "radio" ng-model = "'+ attrs.kmmodel +'" disabled = "True" /> & Lt; / Div> '+' & Lt; / Div & gt; '+' & Lt; / Div & gt; & Lt; / Div & gt; '; ;}}}}

The following code is the answer to the function call ible

  '& lt; Li class = "rowlist" ng-repeat = "'+ repeat +" "& gt; & Amp; Nbsp; {{N}} & lt; Input type = "radio" ng-model = "'+ attrs.kmModel +'" name = "a" ng-click = "radio value change (n, '+ attrs.kmmodel +')" /> & Lt; / Options & gt; '$ $ Radius radio value change = function (value, model) {// warning ("converted value" + value + model); Warning (value + "and" + model); // warning ("model" + model); }   

In HTML, I have a code like below

    
  app.directive ('kmRadio', function ($ parse) {return {restricted: 'e', ​​replace: correct, templatesURL : 'KimRDOOHML', scope: true, link: function (scope, element, ether) {sko .kmmdel = area. $ Aval (atr.kmmdel); scope.binding = etter .kmModel; scope.title = attr.title; scope.kmOption = scope. $ Eval (attr.kmOption);}}})   

Where is kmRadio.html :

  & lt; Div & gt; & Lt; Div = ng-switch = "format" & gt; & Lt; div ng-switch-when = "kmForm" & gt; & Lt; Div & gt; & Lt; div class = "floatLeft" & gt; {{Title}} & lt; / Div & gt; & Lt; Ul & gt; & Lt; Li class = "row list" ng-repeat = "k in nopackoption" & gt; {{N}} & lt; Input type = "radio" ng-model = "$ parent.km model" ng-click = "radio value change (n, binding)" ng-value = "n" /> & Lt; / li & gt; & Lt; / Ul & gt; Forced: {{binding}}, value: {{kmModel}} & lt; / Div & gt; & Lt; / Div & gt; & Lt; Div ng-switch-when = "kmpreview" & gt; & Lt; Div & gt; {{Title}} & lt; Input type = "radio" ng-model = "km model" disabled = "true" /> & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;   

Here is a working demo:

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -