Sangram Singh
Sangram Singh

Reputation: 7191

rendered partial x.jade is interpreted as html in Angularjs

angular.module('myApp', []).
config(['$routeProvider', function($routeProvider) {
  $routeProvider.
    when('/', {templateUrl: 'partials/some.jade',  controller: myAppController}).      
    otherwise({redirectTo: '/login'
  });
}]);

The above code loads the some.jade partial, but treats it like html thus h1 try me which should be rendered as <h1> try me </h1> is simply rendered as plain text h1 try me

Edit: backend

app.configure(function(){
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.favicon()); 
  app.use(express.logger('dev'));
  app.use(express.static(__dirname + '/public'));
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(app.router);
});

app.get('/', function(req,res){

    //res.send('hi');
    res.render('login', { title: 'Express' });

});

Upvotes: 1

Views: 912

Answers (2)

user3567217
user3567217

Reputation: 1

when('/', {templateUrl: 'partials/some.jade', controller: myAppController})

should be like this if the jade file is 'some.jade' :

when('/', {templateUrl: 'partials/some', controller: myAppController})

Upvotes: 0

Brian Lewis
Brian Lewis

Reputation: 5729

Try dropping the .jade extension and add this to your express config.

app.get('/partials/:name', function (req, res) {
    var name = req.params.name;
    res.render('partials/' + name);
});

Upvotes: 1

Related Questions