Use rootScope variables in my html

前端 未结 5 1041
我寻月下人不归
我寻月下人不归 2020-12-24 10:16

So we can use scope variables in our angular html easily like this:



  
    

        
5条回答
  •  一向
    一向 (楼主)
    2020-12-24 11:00

    you could inject $rootScope in you controller and then map it to a scope variable like this

    $scope.global = $rootScope;

    then in your template you could use

    $rootscope value of name is {{ global.name }}.

    You have to be careful to not uselessly put thing into the $rootScope as it's not considered the best practice to modulate your code

提交回复
热议问题