Dynamic ng-model binding inside a directive

前端 未结 1 1229
春和景丽
春和景丽 2020-12-31 05:40

I\'m trying to create a custom component that uses a dynamic ng-model inside-out the directive.

As an example, I could invoke different components like:



        
1条回答
  •  感动是毒
    2020-12-31 05:58

    Something like this?

    http://jsfiddle.net/bateast/RJmhB/1/

    HTML:

    
        
        
    
    

    JS:

    angular.module('test', [])
        .directive('myDir', function() {
            return {
                restrict: 'E',
                scope: {
                    ngModel: '='
                },
                template: '
    ', }; });

    0 讨论(0)
提交回复
热议问题