Jade Mixins in AngularJS

Hi, I would like to use Jade templates in my AngularJS project and have mixin in my template (reusable code).

However, the problem I am facing is that we cannot use Mixin with arguments. Am I doing this right or is there an alternative for the same in AngularJS that I am missing?

+4
source share
2 answers

I realized that mixins cannot be used in Angular, since the scope should be defined. Therefore, the element directive is now created and passed in the template (which was to be written in Mixin) as a template in it.

0
source

You can create a js object from your model and pass it as strings to mixin, as shown below:

+avatarRow({name: '{{avatar.name}}', uuid: '{{avatar.uuid}}', verificationCode: '{{avatar.verificationCode}}', status: '{{avatar.status}}'}) 

Inside the mix, you can now access, for example. #{avatar.uuid}

I believe that automate this further, because it leads to duplication of model code, which is not so good. I will share my decision if I get it :)

+3
source

Source: https://habr.com/ru/post/1499574/


All Articles