When do isolated scope properties actually get added to the scope?

后端 未结 2 588
小蘑菇
小蘑菇 2021-01-19 12:00

I\'m creating some directives with an isolated scope and some aliased properties. For example:

scope: {
   prop1: \'@\'
}

My question is, w

2条回答
  •  忘掉有多难
    2021-01-19 12:39

    I found that this works inside the directive definition:

    scope: {
        prop1: '@'
    },
    link: function(scope, element, attrs) {
        ...
        attrs.$observe('prop1', function(val) { 
            scope.prop1 = val || 'default'
        });
        ...
    }
    

    to make

    behave like

提交回复
热议问题