Angular using ng-model with expression in directive template

后端 未结 2 808
小蘑菇
小蘑菇 2021-01-11 16:05

I want to use the ng-model attribute in a custom element. The problem is, that I need to set the ng-model with an expression:

ng-model=\"{{anyVariable}}\"
         


        
2条回答
  •  再見小時候
    2021-01-11 16:36

    Try a version of this:

    .directive('myDir', function() {
        return {
            restrict: 'EA',
            scope:    {
                        YYY: '=ngModel'
                      },
            require:  'ngModel',
            replace:  true,
            template: ''
        };
    });
    

提交回复
热议问题