I'm trying to display the first image in an array that is fed into my directive, however, I do not understand why this doesn't work. Can you please explain?
Script.js file:
angular.module('app',[])
.controller('MyController', function() {
var self = this;
self.imageList=[
'https://upload.wikimedia.org/wikipedia/commons/3/3d/Polar_Bear_AdF.jpg',
'http://www.polarbearsinternational.org/sites/default/files/styles/media_full/public/00473-10104_0.jpg?itok=uv9Mr5rz',
'http://www.polarbearsinternational.org/sites/default/files/styles/inside_full/public/sca-000005.jpg?itok=7HybQm2o'
];
})
.directive('myImageGallery', function(){
return {
restrict: 'E',
scope:{
images: '='
},
controller: function() {
},
controllerAs: 'vm',
template: '<ul><img images="vm.images" ng-src={{ vm.images[0] }}</li></ul>'
}
})
HTML:
<body ng-app="app">
<div ng-controller="MyController as myCtrl">
<my-image-gallery images="myCtrl.imageList"></my-image-gallery>
</div>
</body>