AngularJS中的全局设置
发布时间:2020-12-17 07:33:39 所属栏目:安全 来源:网络整理
导读:我有一个必须可自定义的应用程序,一个参数是网址的根目录.该应用程序不一定是网站的根源,即.它可以在 http://onedomain.com/index.html托管,其中appName将是/,因为它可以在 http://anotherdomain.com/myapp/index.html托管,其中appName将是/ myapp /. 但我需
我有一个必须可自定义的应用程序,一个参数是网址的根目录.该应用程序不一定是网站的根源,即.它可以在
http://onedomain.com/index.html托管,其中appName将是/,因为它可以在
http://anotherdomain.com/myapp/index.html托管,其中appName将是/ myapp /.
但我需要知道路由器中的appName,所以在我的模块的configFn中,要做这种事情: return $routeProvider.when(appName + "index.html",{ templateUrl: 'views/main.html',controller: 'MainCtrl' }) 由于我有更多参数,我启动了一个名为Settings的服务,但在配置模块时无法注入服务… 你会怎么做? 对于我的担心,我开始考虑自定义提供商,但我不确定它是否合适.
对于设置相关信息,我使用
constant:
angular.module(...) .constant("APPNAME","/myapp/") .controller(...,function(...,APPNAME) {...}) 这是一个说明常数的simple plunker. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |