Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. 'use strict';
  2. angular.module('myApp').directive('listImg', function() {
  3. return {
  4. retrict: 'E',
  5. templateUrl: 'templates/list-img.html',
  6. scope: {
  7. show: '@',
  8. },
  9. link: function($scope) {
  10.  
  11. $scope.iconImg;
  12.  
  13. if ($scope.show == "opt1") {
  14. $scope.iconImg = "images/img1.png";
  15. } else if ($scope.show == "opt2") {
  16. $scope.iconImg = "images/img2.png";
  17. } else if ($scope.show == "opt3") {
  18. $scope.iconImg = "images/img3.png";
  19. } else if ($scope.show == "opt4") {
  20. $scope.iconImg = "images/img4.png";
  21. }
  22.  
  23. }
  24. }
  25. });
  26.  
  27. <img ng-if="show" ng-src="{{iconImg}}" class="list-image">
  28.  
  29. <list-img show="{{item.opt1 ? 'opt1' : ''}}"></list-img>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement