Chrome网上应用店安装的内嵌有AngularJS [英] Chrome Webstore inline installation with AngularJS
问题描述
我和AngularJS一个新手,并试图安装一个Chrome扩展后的网络商店在线安装指南一>
I'm a newbie with AngularJS and trying to install a Chrome extension following the Webstore inline installation guide
在我的.html文件
<button data-ng-click="chromeExtensionInstall()" id="install-button">Add to Chrome</button>
在我的.js文件
function successCallback () {
window.alert('success');
}
function failureCallback () {
window.alert('failure');
}
$scope.chromeExtensionInstall = function() {
if (!chrome.app.isInstalled) {
chrome.webstore.install('https://chrome.google.com/webstore/detail/...',
successCallback(), failureCallback());
}
};
这两个警报显示,然后让这个未捕获的异常:Chrome网上应用店安装只能由用户手势来initated
Both alerts are displayed and then getting this Uncaught Exception: "Chrome Web Store installations can only be initated by a user gesture"
你知道吗?
提前致谢。鸭preciate任何帮助。
Any idea? Thanks in advance. Appreciate any help.
推荐答案
chrome.webstore.install
函数接受2回调参数,这意味着两个指针的功能。你不应该自己调用这些功能,但只是在传递自己的名字,像这样的:
chrome.webstore.install
function accept 2 callback parameters, which means 2 pointers to function. You should not call those functions yourself, but just pass in their names, like this:
chrome.webstore.install('https://chrome.google.com/webstore/detail/...',
successCallback, failureCallback);
而不是这样的:
chrome.webstore.install('https://chrome.google.com/webstore/detail/...',
successCallback(), failureCallback());
你看有什么区别?如果你不这样做,对此页这也解释得很好(也有这7常见的JavaScript错误的)
Do you see the difference ? If you don't, have a look on this page which explains it well (and there's also this on 7 common JavaScript mistakes)
这篇关于Chrome网上应用店安装的内嵌有AngularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!