我有几篇关于这方面的文章,但没有得到适合我的问题的解决方案。我采用了棱角分明的js 1.5和Bootstrap 3如何通过Angular js获取元素的ID
我的代码是什么样子,
<a href="" class="noUnderline" data-trigger="focus" data-toggle="popover" data-placement="bottom" data-content = "{{helpSrv.helpMessage}}" >
<i class="fa fa-info-circle infoCirc" ng-click="helpSrv.showPopOverInfo($event)" id="forecastAttainmentId"> </i>
</a>
我想说明的酥料饼时,将点击i
图标。现在,helpSrv
是用Angular JS编写的一项服务。 helpMessage
由元素的id
选择。 helpSrv
是包含像两件事服务,
var s = this
s.helpInfo = {
"forecastAttainmentId": "Some text"
}
s.showPopOverInfo = function (event) {
var helpSelect = event.target.id
s.helpMessage = s.helpInfo[helpSelect]
console.log(s.helpMessage)
}
现在,当我点击了第一次i
图标它显示在酥料饼{{helpSrv.helpMessage}}
。下次显示实际信息,即Some text
。我认为延迟是由于函数调用造成的。如何解决?或者有什么办法可以使用angular(不带任何插件)自动获取元素的id
,这样我就可以使用data-content="{{helpSrv.helpInfo['id of the element']}}"
来获取Popover的消息。
它真的是'ng-lick'吗?你拼错了,它应该是'ng-click' – pryxen