AngularJS transcluded nested directive -


I'm trying to create an angle command like this:

   

The main goals are being reused and each & lt; Input type = "radio" ng-model = "myModel.attribute"> gt; and code repeats in general.

I have written the following:


formjs.js

  Var franz module = angular Modules ('HP Forms', []); // Director: formjsModule.directive ('radioButtonGroup', function () {return {restricted: 'e', ​​passed: true, scope: {dataModel: '@', group: '@', label: '@?'}, TemplateUrl: function (amm, atri) {return 'formjs / radio / radio-group-tpl.html';}}}) Instructions ('radio button', function () {return {restricted: 'e', ​​requirement: [ '^ Radio Baitan Group'], Translact: True, Scope: {Value: '@', Datamodel: '@', Group: '@'}, TemplateUurl: Function (AMM, Attri) {Return 'Forms / Radio / Radio -item -tpl.html ';}}});  

formjs / radio / radio-item-tpl.html

  & lt; Input type = "radio" name = "{{group}}" id = "{{group + '_' + id}}" ng-value = "value" ng-model = "data model" />  

formjs / radio / radio-group-tpl.html {{label}} m: {{dataModel}}

  & lt; Div class = "col-sm-10" id = "g _ {{group}}" ng-transcl & gt; & Lt; / Div & gt; & Lt; / Div & gt;  

I am aware of the mutual realm, but I do not see a great way of doing this bond.

Help, please!

Should it be instructed? Will not it be enough?

  // HTML template & lt; Div ng-repeat = "option in options" & gt; & Lt; Input type = "radio" ng-model = "$ parent.selected" ng-value = "options" & gt; {{Option}} & lt; / Div & gt; ... // $ controller $ scope. Selected = null; $ Scope.options = ['Radio One', 'Radio Two', 'Radio Three'];  

Enter image details here


< P> Of course, if you insist, you can direct it.

The use of HTML, where option is the array as above.

  & lt; Radio group group-name = "my group" ng-model = "selected" option = "option" & gt; & Lt; / Radio-group & gt;  

Actual Directive

  App Directional ('radio group', function () {return {restricted: 'e', ​​scope: {groupName: @ ',' Option: '=', ngModel: '='}, Template: 'Legend & gt; {{groupName}} & lt; / legend & gt;' + '& lt; div ng- Repeat = "Option in option"> "+ '& Lt; input type =" radio "' + 'ng-model =" $ parent.ngModel "ng-value =" option "& gt; {{option}}' + '& Lt; / div & gt;'}}});  

imgur


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -