Angularjs - can't pass variable to directive -


i have code below. predictions['team1 expected goals'] comes undefined in donutchart.js directive though value defined on second line. how pass directive?

<div>   <div>{{ (fixture.team1.name.short_name || fixture.team1.name.gsm_name) }}</div>   <div>{{ predictions['team1 expected goals'] | number : 2  }}</div> </div> <div>   <donut-chart team1="predictions['team1 expected goals']"                 team2="predictions['team2 expected goals']">   </donut-chart> </div> 

the below works expected:

<donut-chart team1="1.26" team2="0.81"></donut-chart> 

here code donutchart.js directive. note structure is, overall controller calls directive (called models-prices) calls chart directive.

angular.module('stratabet') .directive('donutchart', function(appversion) {   'use strict';    var directive = {     priority: 0,     restrict: 'e',     scope: {       team1: '=',       team2: '='     },     controller: function($scope) {       console.log('donutchart controller - team1: ' + $scope.team1 + ', team2: ' + $scope.team2);     },     link: function(scope, element, attrs) {       console.log('donutchart - team1: ' + scope.tea1 + ', team2: ' + scope.team2); } } 

in line,

console.log('donutchart - team1: ' + scope.tea1 + ', team2: ' + scope.team2); 

there typo in scope.tea1, should $scope.team1 there no property tea1 on scope

it should be

console.log('donutchart - team1: ' + scope.team1 + ', team2: ' + scope.team2); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -