angularjs directive set template url dynamically

后端 未结 4 2140
刺人心
刺人心 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-19 22:56

    Why not do:

    template : '
    '

    then:

    $scope.getActualTemplateContent= function() {
      return '../assets/common/headerMenu/' + $scope.user_role + '.html';
    };
    

提交回复
热议问题