AngularJS + jQuery - Unable to hide / show element inside directive

I have an element that I am displaying on the web page - this element is a twitter bootstrap icon - ``. When the page loads, the icon is hidden by applying the hidden class to it with the style: .hidden { display: none; } Now, I have created a directive which in its simplest form looks like: var app = angular.module('testApp', []); app.directive('testDir', function() { return function(scope, iElement, iAttrs) { iElement.customMethod({ source: function() { //Some other statements jQuery(".icon-trash").removeClass('hidden'); } }); }; }); This directive is placed on an input box as an attribute. When the user enters an input text, the directive function is indeed called. However, the icon is never displayed again, that is the jQuery code does not seem to remove the hidden class even though the function is called (checked using `console.log()`). Any idea why?
I think you should read stackoverflow.com/questions/14994391/… and consider using ng-class instead of writing a complex directive ?

以上就是AngularJS + jQuery - Unable to hide / show element inside directive的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏