Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何获取元素';s id由角js生成_Javascript_Jquery_Angularjs_Twitter Bootstrap - Fatal编程技术网

Javascript 如何获取元素';s id由角js生成

Javascript 如何获取元素';s id由角js生成,javascript,jquery,angularjs,twitter-bootstrap,Javascript,Jquery,Angularjs,Twitter Bootstrap,我有几篇关于这方面的文章,但没有找到解决问题的正确方法。我使用的是AngularJS1.5和Bootstrap3 我的代码是 <a href="" class="noUnderline" data-trigger="focus" data-toggle="popover" data-placement="bottom" data-content = "{{helpSrv.helpMessage}}" > <i class="fa fa-info-circle infoCi

我有几篇关于这方面的文章,但没有找到解决问题的正确方法。我使用的是AngularJS1.5和Bootstrap3

我的代码是

<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.helpMessage}}
。下次它显示实际消息时,即
一些文本
。我认为延迟是由于函数调用引起的。如何解决这个问题??或者是否有任何方法可以使用angular(无任何插件)自动获取元素的
id
,这样我就可以使用
数据内容=“{helpSrv.helpInfo['id of the element']}}”
来获取Popover的消息。

您可以使用jQuery通过
$(“#forecastAttainmentId”)访问
I
标记。单击(函数)(){…}
。您还需要初始化
helpSrv.helpMessage
,以便在popover第一次加载时能够看到数据。

它是关于。尝试使用$timeout:

s.showPopOverInfo = function (event) {     
    $timeout(function(){ 
        var helpSelect = event.target.id; // Always end lines with a semicolon
        s.helpMessage = s.helpInfo[helpSelect];
        console.log(s.helpMessage);
    }, 0);
};

它真的是
ng lick
?你错发了,它应该是
ng click
我用了$timeout。但仍然没有帮助。请在JSFIDLE或jsbin等上创建一个示例。
s.showPopOverInfo = function (event) {     
    $timeout(function(){ 
        var helpSelect = event.target.id; // Always end lines with a semicolon
        s.helpMessage = s.helpInfo[helpSelect];
        console.log(s.helpMessage);
    }, 0);
};