Passing data to a custom directive in AngularJS -
Passing data to a custom directive in AngularJS -
i have page displays bunch of thumbnails of images retrieved using http. utilize ng-repeat go through array , generate html. works fine. create custom directive tie attribute img elements generated ng-repeat. works fine. however, when seek pass info scope of custom directive falls apart. info binding fails, ng-repeat not replace url of images end getting 404 since url invalid. pretty much far goes. help appreciated since new angular.
my html template:
<div class="portfoliocontent"> <div class="row"> <div class="col-lg-3 col-md-4 col-sm-4 col-xs-6 col-padding" ng-repeat="gimg in gphotos"> <div class="photoframe"> <img src="{{gimg.thumbnailurl}}" url="{{gimg.imageurl}}" image-gallery> </div> </div> and custom directive:
myapp.directive('imagegallery',function(){ homecoming { restrict: 'a', scope: { url: '=' }, controller: function($scope){ console.log($scope.url); } } });
try changing
scope: { url: '=' }, to
scope: { url: '@' }, see here simple example. check console. see here difference between = , @.
angularjs angularjs-directive
Comments
Post a Comment