AngularJS Expression in Expression

前端 未结 3 766
长情又很酷
长情又很酷 2021-01-02 17:37

Is there a way to have AngularJS evaluate an expression within model data?

HTML:

{{Txt}}


Model:

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-02 17:58

    You can execute JS within the brackets:

    {{Txt + ' ' + Rest}}

    Or create a function that returns the text you want:

    $scope.getText = function() {
      return $scope.Txt + ' ' + $scope.Rest;
    }
    
    

    {{getText()}}

提交回复
热议问题