I am having trouble getting my directive to provide its contents only after my promise is resolved. I thought then() should have done this, but it does not seem to work.
Here is my controller:
// Generated by CoffeeScript 1.6.3 (function() { var sprangularControllers; sprangularControllers = angular.module('sprangularControllers', ['sprangularServices', 'ngRoute']); sprangularControllers.controller('productsController', [ '$scope', '$route', '$routeParams', 'Product', 'Taxonomy', function($scope, $route, $routeParams, Product, Taxonomy) { Taxonomy.taxonomies_with_meta().$promise.then(function(response) { return $scope.taxonomies = response.taxonomies; }); return Product.find($routeParams.id).$promise.then(function(response) { return $scope.currentProduct = response; }); } ]); }).call(this);
My directive:
// Generated by CoffeeScript 1.6.3 (function() { var sprangularDirectives; sprangularDirectives = angular.module('sprangularDirectives', []); sprangularDirectives.directive('productDirective', function() { return { scope: { product: '=' }, templateUrl: 'partials/product/_product.html', link: function(scope, el, attrs) { console.log(scope); console.log(scope.product); return el.text(scope.product.name); } }; }); }).call(this);
The scope returns in order, and when I check it in dev tools, scope.product not undefined, however, I assume that since I check that the promise has been resolved?
console.log(scope.product) , however, returns undefined ..
javascript angularjs angularjs-directive
Melbourne2991 Jan 17 '14 at 3:57 on 2014-01-17 03:57
source share