星期五, 3月 27, 2015

[AngularJS] 小踩雷筆記: ng-class的css name使用-符合

如果你的class name使用了-符號,搭配使用ng-class時,請加上''符號,不然則會失效
請參考: http://stackoverflow.com/questions/15557151/ngclass-style-with-dash-in-key
After hours of hacking around, it turns out the dash gets interpolated! Quotes are needed.
 class="icon-home" ng-class="{'icon-white': someBooleanValue}">
I hope this helps someone from tearing their hair out.
UPDATE:
In older versions of Angular, using a backslash also does the trick, but not in the newer versions.
 class="icon-home" ng-class="{icon\-white: someBooleanValue}">
The former is probably preferred, since you can search for it in your favorite editor.

星期六, 3月 14, 2015

[AngularJS] 小踩雷筆記: button鈕點擊一直發生submit form的動作

今日踩雷小筆記: 如果你在form表單裡放了button鈕,並自行綁定ng-click方法時,如果html的button忘記加入type="button", angular將會貼心幫你觸發form submit XD

星期四, 3月 12, 2015

[Java] JPA 使用IN查詢

由於不習慣用jpa來操作db,第一次要使用in查詢式就踩雷了。
成功的方法如下:

  String cmd = "SELECT d FROM Device d  WHERE d.agentId IN :agentId";
            Query query  = entityManager.createQuery(cmd);
            query.setParameter("agentId", dealAgentIds);

備註: 

  • 不要把 :agentId多包一個括號,例如(:agentId),會炸給你看的。 
  • d.agentId是你產生結構裡面的欄位命名,不要用原本database的欄位。

其他你感興趣的文章

Related Posts with Thumbnails