Dynamically set the value of ui-sref Angularjs

前端 未结 12 1803
囚心锁ツ
囚心锁ツ 2020-11-28 04:15

I have searched for a similar question but the ones that came up seem slightly different. I am trying to change the ui-sref=\'\' of a link dynamically (this link points to t

12条回答
  •  爱一瞬间的悲伤
    2020-11-28 04:55

    I managed to implement it this way (I'm using the controllerAs variant though - not via $scope).

    Template

    
    

    Controller

    var vm = this;
    vm.locale = 'en'; // or whatever dynamic value you prepare
    

    Also see the documentation to ui-sref where you can pass params:

    https://github.com/angular-ui/ui-router/wiki/Quick-Reference#ui-sref

提交回复
热议问题