I'm coding with AngularJS version 1.5.7.
For some reason, the directive doesn't receive the variable cdata
which is an object
.
Why doesn't the directive receive the variable?
Here below I pasted all my code:
home.js
'use strict';
var home = angular.module('app.home', [
'global.factory',
'home.factory',
'ui.scroll',
'ui.scroll.jqlite',
'd.card'
]);
home.controller('HomeController', [
'homeFactory',
'$timeout',
function (homeFactory, $timeout) {
var data = this;
data.posterSize = (screen.width - 42) / 3;
homeFactory.getJSON().then(function (response) {
data.feed = response.home;
});
data.datasource = {
get: function(index, count, success) {
$timeout(function() {
var start = Math.max(0, index);
var end = Math.min(index + count, data.feed.length);
var results = [];
for (var i = start; i < end; i++) {
results.push(data.feed[i]);
}
success(results);
}, 100);
}
};
}
]);
_home.html
<article ng-controller="HomeController as myHome" class="base-gen" ui-scroll-viewport style="height:100%">
<card class="card" ui-scroll="element in myHome.datasource" cdata="{{element}}" psize="{{myHome.posterSize}}"></card>
</article>
card.js
'use strict';
var dCard = angular.module('d.card', ['global.factory']);
dCard.directive('card', [ 'globalImages', function (globalImages) {
return {
restrict: 'E',
scope: {
cdata: '@',
psize: '@'
},
controller: function() {
console.log(this.cdata);
},
controllerAs: 'myCard',
bindToController: true,
templateUrl: 'app/Modules/card.html'
};
}]);
I also want to point out that I've migrated from angular 1.4.8
to 1.5.7
and from ui-router 0.2.15
to 0.3.1