angularjs directive set template url dynamically

后端 未结 4 2162
刺人心
刺人心 2021-02-19 22:19

I\'m creating a directive with template URL. I want to set the template URL dynamically based on user_role. Any idea?

Heres my directive code:

RatingRX.d         


        
4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-19 22:43

    You can pass a function to the templateUrl option and return a string that will be used as a template url at the end.

    First of all assign a role onto the element as an attribute (where userRole is bound to scope) as:

    Update: This used to work before with older version of Angular.

提交回复
热议问题