I'm learning angular, and have this weird problem: my index includes:
<script src="js/controllers.js"></script>
<script src="js/directives.js"></script>
And I have this code:
angular.module('myApp.directives', []).directive('myYoutube', function($sce) {
return {
restrict: 'EA',
scope: { code:'=',add:'=' },
replace: true,
template: '<div style="height:400px;"><iframe style="overflow:hidden;height:100%;width:100%" width="100%" height="100%" src ="{{url}}" frameborder="0" allowfullscreen></iframe></div>',
link: function (scope) {
console.log('here');
scope.$watch('code', function (newVal) {
if ($sce.isEnabled()){
console.log('and');}
if (newVal) {
console.log('there');
scope.url= $sce.trustAsResourceUrl("http://www.youtube.com/embed/" + newVal);
}
});
}
};
});
When I put it in controllers.js it runs fine. But when I put it in directives.js, I get this error:
GET
http://localhost:8000/app/%7B%7Burl%7D%7D404 (Not Found)
Which points out that {{url}} isn't evaluated. The question is why?
,