在<script> </script>中将$ scope添加到url params

时间:2017-03-21 11:10:49

标签: javascript angularjs

在我的angularjs应用程序中,我在我的身体中有mibew聊天的脚本,这是我的所有脚本

<script type="text/javascript">Mibew.ChatPopup.init({"id":"58cfa9cad9451969","url":"http://steora.com\/mibew-chat\/chat?locale=en&email={{authentication .username}}.com&name={{authentication .username}}","preferIFrame":true,"modSecurity":false,"width":640,"height":480,"resizable":true,"styleLoader":"\/mibew-chat\/chat\/style\/popup"});

我需要设置用户名和电子邮件{{authentication .username}{{authentication .email}}

在我的indexCtrl.js中我这样做

$scope.authentication.username = 'Tom';
$scope.authentication.email= 'tom@gmail.com';

但这不起作用。

有人可以告诉我如何将数据范围扩展到 日Thnx

编辑: 我尝试@KoIIIeY的解决方案,但如果我尝试使用这个,每次我点击聊天图标,它在新标签中打开而不是弹出窗口,并且没有来自电子邮件和用户名的数据。我需要找到如何从控制器传递此数据的解决方案

$scope.authentication.username = 'Tom';

$ scope.authentication.email =&#39; tom@gmail.com' ;;

到index.html。

<script type="text/javascript">Mibew.ChatPopup.init({"id":"58cfa9cad9451969","url":"http://steora.com\/mibew-chat\/chat?locale=en&email=_____HERE_____&name=____HERE____","preferIFrame":true,"modSecurity":false,"width":640,"height":480,"resizable":true,"styleLoader":"\/mibew-chat\/chat\/style\/popup"})></script>

1 个答案:

答案 0 :(得分:1)

indexCtrl.js中的

$scope.init = function(){
    Mibew.ChatPopup.init({"id":"58cfa9cad9451969","url":"http://steora.com\/mibew-chat\/chat?locale=en&email="+$scopeauthentication.email+".com&name="+$scopeauthentication.username+"","preferIFrame":true,"modSecurity":false,"width":640,"height":480,"resizable":true,"styleLoader":"\/mibew-chat\/chat\/style\/popup"});
}

在视图中

<body ng-init="init()"></body>