vuquanghoang
vuquanghoang

Reputation: 369

Angular cannot parse data-binding within directive

I try to create a simple angular app. Its logic looks like:

  1. Enter a city name (for example: haiphong)

  2. Click search -> There will be result showed-> Click on the result -> The map is updated to the new location -> click on the marker -> There will be an info box to show the information.

However, the direction seems to keep the expression as original. Do you have any ideas?

enter image description here

This is what I used to get the info box (inside controller), you can see in detail by plunker link:

$scope.getInfoBoxContent = function (index) { var content = '<div today-info-directive details="' + index +'"></div>'; var compiled = $compile(content)($scope); console.log('compiled', compiled); return compiled[0]; }

http://plnkr.co/edit/pHjqHGNupAZnO5ORSjQW?p=preview

The directive seems to include its template but not parse the expression (for example: {{1+2}})

Upvotes: 1

Views: 66

Answers (1)

qwerty_igor
qwerty_igor

Reputation: 949

use templateUrl, remove all '\' characters copy directive template onto another file and provide it's url to templateUrl of the directive. see if it works. just tested on your fiddle and it did

Upvotes: 1

Related Questions