javascript - Error with binding an attribute value - angular include and directives -



javascript - Error with binding an attribute value - angular include and directives -

i trying include directives dynamically according info receive server. have asked this before , directive uploaded, there error see in console, here get: syntax error: token 'type' unexpected, expecting [:] @ column 3 of look [{{type}}] starting @ [type}}].

here main page html:

<div ng-repeat="type in bet.bet_types"> <div ng-include src="getbettypebyid(type.id)"></div> </div>

here getbettypebyid(id) function scope:

$scope.getbettypebyid = function(id) { switch(id) { case 1: homecoming '/views/partials/1.html'; break; ...

here 1.html:

<test-test bettype={{type}}></test-test>

here tets-test directive:

var app = angular.module('soccerwinner', []); app.directive('testtest', function() { homecoming { restrict: 'e', replace: true, scope: { bettype: '=' }, templateurl: '/views/partials/directives/bettaype_soccer_winner.html', controller: function() { alert('dfd'); } }; });

and here bettaype_soccer_winner.html:

<h2>test</h2>

there no alert after directives loaded, , above error seen in console.

what wrong do? believe issue related line of code <test-test bettype={{type}}></test-test>

here sample of type:

{"id":1,"name":"winning team or tie","description":"choose winnig team.","schema":"{\n\t \t'winnerid': 'integer',\n 'options:' []\n\t }","created_at":"2014-06-22 13:13:07","updated_at":"2014-06-22 13:13:07","pivot":{"bet_id":1,"bet_type_id":1},"userbet":""}

you should passing model directive. not expression. remove curly brackets, should trick.

<test-test bettype="type"></test-test>

cheers

javascript html angularjs web angularjs-directive

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -