Masonry with AngularJS

后端 未结 6 1518
情书的邮戳
情书的邮戳 2021-01-29 22:28

I am developing an \"art gallery\" app.

Feel free to pull down the source on github and play around with it.

Plunker with full

6条回答
  •  醉酒成梦
    2021-01-29 23:25

    One of the least documented feature of Angular is its Directive Controllers ( though it is on the front page of www.angularjs.org - Tabs ).

    Here is a modified plunker that makes use of this mechanism.

    http://plnkr.co/edit/NmV3m6DZFSpIkQOAjRRE

    People do use Directive Controllers but it has been used ( and abused ) for things it probably was not meant for.

    In the plunker above I have only modified the directives.js file. Directive controllers are a mechanism for communication between directives. Sometimes , it is not sufficient / easy to do everything in one directive. In this case, you have already created two directives but the right way to make them interact is through a directive controller.

    I was not able to figure out when you wanted to prepend and when you wanted to append. I have only implemented "append" currently.

    Also on a side note : If resources doesnt already implement promises, you can implement them yourself. It isnt really hard to do that. I noticed you are using a callback mechanism (which I wouldnt recommend ). You have already put in promises there but still you are using callbacks which I was not able to understand why.

    Does this provide a proper solution to your problem ?

    For documentation see http://docs.angularjs.org/guide/directive > Directive Definition Object > controller.

提交回复
热议问题