如果你的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.
沒有留言:
張貼留言
留個話吧:)