0

I would like to pass strings into textAngular so that $scope properties are compiled For example

$scope.text = "Hey {{person.name}}";

Then in the HTML I have

 <div text-angular ng-model="text"></div>

Temporarily I put together a hack for my controller.

$scope.$watch(function(){return $scope.text;}, function(html) {
        $scope.text = $interpolate($scope.text)($scope);
});

How do I turn this hack into a directive that plays nice with textAngular?

Jakobovski
  • 3,203
  • 1
  • 31
  • 38
  • can you not interpolate it once inside callback when it is received and get rid of `$watch`? – charlietfl Aug 05 '15 at 00:59
  • @charlietfl I dont understand. Can you elaborate? – Jakobovski Aug 05 '15 at 16:43
  • Show where `$scope.text` gets called from server. Can't you just interpolate it in that callback? Not really sure how your template system in the editor is supposed to work also – charlietfl Aug 05 '15 at 16:47
  • I could do that, but then when the $scope value changes the text is not updated. – Jakobovski Aug 06 '15 at 18:44
  • again...it is not very clear how you are trying to use this. My assumption from trivial example given was you only wanted to set it once when loaded – charlietfl Aug 06 '15 at 19:02

1 Answers1

0

I think that what you should be doing is this:

$scope.text = "Hey "+$scope.person.name;

Realistically once you put the text in the ngModel, the user can change the text.

Michele Ricciardi
  • 2,107
  • 14
  • 17