[英]firefox sdk add-on using angularJs routing
I've created a small chrome extension using angularJs with this structure 我使用此结构使用angularJs创建了一个小的chrome扩展
extension/
statics/
css/
js/
lib/
app/
api/
img/
views/
partials/
all Js files containing angularJs functionality are in js/app folder, and all files related to chrome API are in js/api folder. 所有包含angularJs功能的Js文件都位于js / app文件夹中,而与chrome API相关的所有文件都位于js / api文件夹中。 in manifest json file 在清单json文件中
"default_popup": "popup.html#/popup"
helps me invoke controller of popup route. 帮助我调用弹出路径的控制器。 and I can change the route for options tab(in a new tab): 我可以更改“选项”标签的路线(在新标签中):
chrome.tabs.create({url: 'html/application.html#/welcome'});
I want to find out how to define a route for the popup in firefox so that I can reuse this structure to create firefox SDK add-on with. 我想了解如何为firefox中的弹出窗口定义路由,以便我可以重用此结构来创建firefox SDK附加组件。 may you please show me how to? 你能告诉我怎么做吗?
I think I need to answer my own question. 我想我需要回答我自己的问题。
the popup in extensions (firefox & chrome I read about in docs ) won't change the route until next time you click on extension browser action button to open it again, so you can't use multiple routes and multiple controllers. 扩展名中的弹出窗口(我在docs中了解到的firefox和chrome)不会更改路由,除非您下次单击扩展名浏览器操作按钮再次将其打开,因此您不能使用多个路由和多个控制器。 if you need a two way binding for the popup view in AngularJs, you need to do it by a single controller. 如果需要对AngularJs的弹出视图进行双向绑定,则需要由单个控制器完成。 so, the only working approach I found is to invoke the controller manually: 因此,我发现的唯一可行方法是手动调用控制器:
define a function to invoke the controller 定义一个函数来调用控制器
app.invokeManually = function () {
var $injector = angular.bootstrap(document, ['app']);
var $scope = angular.element('body').scope();
$scope.$apply();
}
assuming the body as the control element. 以身体为控制元素。 then call this function at the end of popup body. 然后在弹出式正文的末尾调用此函数。
Let me know if you have a better idea. 让我知道您是否有更好的主意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.