Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
92
rated 0 times [  98] [ 6]  / answers: 1 / hits: 23414  / 11 Years ago, wed, july 17, 2013, 12:00:00

On the video watch page with the url




/watch/video_id




, I had a ng app. The directive is shown as below.



app.directive('myApp', function() {
return {
restrict: 'E',
templateUrl: 'ng-templates/myTemplate.html',
link: function(scope, elem, attrs) {
},
controller: 'Controller'
};
});


Since the templateUrl is the relative path, it will try to find the template in




'/watch/ng-templates/myTemplate.html'




which is an error.



I want to put all the templates in the ng-templates folder. But it won't work if the ng app always looks for the relative path. Is there a way to configure the app making it to look for '/ng-template/myTemplate.html'?


More From » angularjs

 Answers
45

Did you try to add leading slash to templateUrl, like



templateUrl: '/ng-templates/myTemplate.html', 

[#76923] Tuesday, July 16, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
julieth

Total Points: 382
Total Questions: 99
Total Answers: 85

Location: Cape Verde
Member since Fri, Nov 27, 2020
4 Years ago
julieth questions
;