Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS-2 custom delimiter

Tags:

angular

I'm trying to do something similar to this interpolateProvider in AngularJS 2 but can not find how to do this similarly

AngularJS 1.x https://docs.angularjs.org/api/ng/provider/$interpolateProvider

$interpolateProvider.startSymbol('//');
$interpolateProvider.endSymbol('//');

checking documentation forAngularJS 2 can not find anything about this. sorry for my English

like image 905
Angel Angel Avatar asked Oct 18 '22 16:10

Angel Angel


1 Answers

It is available from angular 2.0.0-rc2 if I'm not mistaken, at least in current rc4 for sure. It is no longer global setting, but per-component metadata property.

@Component({
    selector: "my-comp",
    templateUrl: "some/url/some-file.html",
    ...,
    interpolation: ["{:!", "!:}"]
})
...

And in component's template some/url/some-file.html you can use those delimiters:

<div>{:!myExpression!:}</div>

BTW - thank you for the interesting question, I've found couple problems in my current project while I was trying to get an answer for you. :)

like image 104
Alexander Leonov Avatar answered Dec 09 '22 20:12

Alexander Leonov