AngularJS Expression in Expression

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

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

HTML:

{{Txt}}


Model:

3条回答
  •  Happy的楠姐
    2021-01-02 18:04

    As you are using javascript for the model you can do something simple like this:

    var rest = 'and this is the rest of it';
    $scope.txt = 'This is some text ' + rest;
    

    And in the view, keep your

    {{txt}}

    Alternatively you can string the expressions together

    {{txt}} {{rest}}

提交回复
热议问题