1

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 !

6
  • It should be relative to your index.html file, I think. Commented Jun 20, 2015 at 9:53
  • Hey you are using express ? If yes what is your static folder in it ? Commented Jun 20, 2015 at 9:54
  • its public @squiroid Commented Jun 20, 2015 at 9:55
  • @Vikash i tried giving '../views/template.jade' and 'template.jade' it doesnot work Commented Jun 20, 2015 at 9:57
  • 1
    So how can you access views on server ? from client side main.js Commented Jun 20, 2015 at 9:57

1 Answer 1

1

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 :)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.