I am trying to call a mixin in jade like this
+projectInfo("assets/images/image.jpg",{{repository.project[projectId].unit}})
error:
Unexpected token { at Function (native) at assertExpression ...
I have also tried like this:
+projectInfo("assets/images/image.jpg",repository.project[projectId].unit)
error:
Cannot read property 'project' of undefined
what am I doing wrong?
update : mixin looks like this
mixin projectInfo(img, title)
.container-fluid
.col-xs-12.projectInfo
.col-xs-12.img
img(src= img)
.col-xs-12.title
h1= title
When you are using AngularJS with Jade, it's better to use directives with own template (powered by Jade if you want as well)
The case you are using it is not really right, jade will be build as html and in that process the value that passed to mixin will be used to draw mixin template instead of +mixinName()
, and as you want to put dynamic value there it's necessary to use AngularJs approach:
angular.module('app.directives').directive('projectInfo', projectInfo);
function projectInfo() {
return {
restrict: 'AE',
//build from jade template and contain {{info.title}}, {{info.img}}
templateUrl: '/templates/myTemplate.html',
scope: {info: '='}
};
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.