angularjs – 我如何以角度重新加载/重新启动服务?
发布时间:2020-12-17 17:28:41 所属栏目:安全 来源:网络整理
导读:如何在不重新加载应用程序的情况下重新启动服务? 我不想使用window.location.reload(). 解决方法 您可以使用工厂而不是简单服务,并在其上创建一个重置方法,将其设置为“初始状态”. 例如,您的工厂可能看起来像这样: function MyFactory() { // generate th
|
如何在不重新加载应用程序的情况下重新启动服务?
我不想使用window.location.reload(). 解决方法
您可以使用工厂而不是简单服务,并在其上创建一个重置方法,将其设置为“初始状态”.
例如,您的工厂可能看起来像这样: function MyFactory() {
// generate the initial structure of the service
let Factory = _getDefaultFactory();
// expose the service properties and methods
return Factory;
/**
* Reset the factory back to its default state
*/
function reset() {
// generate the initial structure again
// and override the current structure of the service
Factory = _getDefaultFactory();
}
/**
* Generate a default service structure
*/
function _getDefaultFactory() {
return {
// include the reset method so you can call it later
// e.g. MyFactory.reset();
reset: reset
// include other factory properties and methods here
};
}
}
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- echarts 3.0 使用自定义图标
- angular – rxjs throttle this.durationSelector不是函数
- angularjs – Angular 2 – JWT auth
- Scala中的自称字段和访问器
- angularjs – 如何从输入复选框中执行angular.js中的函数?
- angularjs – Angular ng-repeat列出具有未知属性名称的对象
- 在现有项目中更新Angular CLI
- angularjs – 在使用“$state.go(‘stateName’,null,{‘re
- 【转】bootstrap, boosting, bagging 几种方法的联系
- VIM默认情况下不加载颜色方案
