I'm using Angular to create a simple directive. I'd like to display the model properties x and y as attributes in the directive. However, instead of the values x and y in scope.textItems, I only get 'item.x' and 'item.y' as the values.
Can one of you tell me why?
thanks!
<div id="b-main-container" class="b-main-container" ng-app="editorApp" ng-controller="EditorCtrl">
<div class="b-grid">
<div id="b-main" class="b-main g1080">
<b-text-el ng-repeat="item in textItems" x="item.x" y="item.y"">
</b-text-el>
</div><!-- end b-main -->
</div>
</div><!-- end grid -->
var myComponent = angular.module('components', []);
myComponent.directive("bTextEl", function () {
return {
restrict:'E',
scope: { },
replace: false,
template: '<span>text</span>',
compile: function compile(tElement, tAttrs, transclude) {
return {
pre: function preLink(scope, iElement, iAttrs, controller) { console.log('here 1'); },
post: function linkFn(scope, element, attrs) {
$(element).draggable();
}
}
}
};
});
var myEditorApp = angular.module('editorApp', ['components']);
function EditorCtrl($scope) {
$scope.textItems = [
{"id": "TextItem 1","x":"50","y":"50"},
{"id": "TextItem 2","x":"100","y":"100"}
];
}