0

Related to that question: Jade Mixins in AngularJS

I have the following (simplified) code:

tr(ng-repeat="avatar in avatars")
    +avatarRow({name: '{{avatar.name}}'})


mixin avatarRow(avatar)
    td avatar.name

Since it is a bit dirty to resolve the "avatar" object before it is passed to the mixin I would prefer a more angular like solution.

Still it would be cool, to keep the mixin code in the same file, but thats not a must. As far as I see, with ngInclude I can no pass any args. So how to handle that?

Continued with this:

tr(ng-repeat="avatar in avatars")
    +avatarRow({name: '{{avatar}}'})


mixin avatarRow(avatar)
    var x = JSON.parse(avatar);
    td x.name

I checked that typeof avatar is string, I can even print it and pass the result to JSON.parse() myself but jade throws a SyntaxError:

Unexpected token { 
    at Object.parse (native)
Community
  • 1
  • 1
Tarion
  • 16,283
  • 13
  • 71
  • 107
  • http://stackoverflow.com/questions/13422966/how-to-specify-model-to-a-nginclude-directive-in-angularjs/20639139#20639139 provides a nice solution but it breaks my Jade IDE support, when i place jade code inside a script ;) But thats smething I could work arround with another mixin. – Tarion Jan 22 '14 at 21:32
  • hm does not realy fork for me yet. – Tarion Jan 22 '14 at 21:42

0 Answers0