AngularJS Expression in Expression

angularjs, angularjs-scope, javascript

Solution

You can use the `$interpolate` service to interpolate the string...

function ctrl ($scope, $interpolate) {
    $scope.Txt = "This is some text {{Rest}}";
    $scope.Rest = "and this is the rest of it.";
    $scope.interpolate = function (value) {
        return $interpolate(value)($scope);
    };
}
<div ng-app ng-controller="ctrl">
    <input ng-model="Txt" size="60" />
    <p>{{ Txt }}</p>
    <p>{{ interpolate(Txt) }}</p>
</div>

JSFiddle

Problem

Is there a way to have AngularJS evaluate an expression within model data? HTML: ``` <p> {{Txt}} </p> ``` Model: ``` { Txt: "This is some text {{Rest}}" } { Rest: "and this is the rest of it." } ``` The end result would be: `This is some text and this is the rest of it`.

Original source