Angular 1.5 component method templateUrl + function

后端 未结 3 1678
温柔的废话
温柔的废话 2020-11-30 11:00

I\'m trying to get an app working with angular 1.5.0-beta.2

To make a \'directive\' I have the following code:

myApp.component(\'gridshow\', {
  bind         


        
3条回答
  •  醉话见心
    2020-11-30 11:56

    In 1.5.0-beta.2 templateUrl can be a function that is invoked by injector. $element and $attrs are injected into both template and templateUrl functions in component, as well as any other dependencies.

    This means that

      ...
      templateUrl: function ($element, $attrs) {
        // access to $element and $attrs
        ...
        return $attrs.uninterpolatedTemplateUrl;
      }
    

    can be done instead.

提交回复
热议问题