Passing ng-model in nested directives

不羁岁月 提交于 2019-12-02 20:08:54

You can set up a bi-directional binding (see the documentation, section "Directive Definition Object") with the variable in ngModel attribute, as with any other directives:

<my-directive ng-model="foo"></my-directive>
myApp.directive('myDirective', function () {
    return {
        template: '<div><input type="text" ng-model="ngModel" /></div>',
        replace: true,
        scope: {
            ngModel : '=',
        },
    };
});

Fiddle

i think you need to pass the form in the directive and set the form dirty manually

<directive directive-form="editForm" ></directive>

scope: {
 directiveForm:"="
 },
 link: function (scope, $elem, $attrs)
 {
  scope.directiveForm.$setDirty(); 
 }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!