Shouvik
Shouvik

Reputation: 447

What should be the correct path of templateUrl in angularJs directive?

I want to give path of templateUrl as a seprate .jade file. But its showing 500 err and Error: [$compile:tpload] .

Below is the code in my directive

app.directive('personRecord',['$http',function(http){
    return{
        restrict : 'AE',
        templateUrl : '../../views/template.jade',
        link : function(scope,ele,attr){

        }
    }
}]);

and my folder structure is like below.

bin
node_modules
public
|-- js
    |-- main.js
routes
views
|-- template.jade
|-- index.jade
app.js
package.json

Please help me out in this ! What am I missing here !

Upvotes: 1

Views: 787

Answers (1)

squiroid
squiroid

Reputation: 14037

My suggestion for you is to put your views folder inside the public folder:-

bin
node_modules
public
|-- js
|    |-- main.js
|--views
    |-- template.jade
    |-- index.jade
routes
app.js
package.json

And then use

app.directive('personRecord', function(http){
    return {
        restrict : 'AE',
        templateUrl : 'views/template.jade',
        link : function(scope, ele, attr){

        }
    };
});

Hope it helps :)

Upvotes: 1

Related Questions