angularjs - ocLazyLoad 和 mathjs
问题描述
老技术栈,希望有人可以伸出援助之手。我正在尝试将 mathjs 库包装在 $scope 中并遇到问题。
我的路线(angular-ui-router,angularjs):
.state('statistics', {
url: '/statistics/{jobTitle}',
views: {
'content': {
template: '<statistics></statistics>',
controller: function($scope, mathController, simpleObj){
console.log(simpleObj);
console.log(mathController);
$scope.$on('ocLazyLoad.fileLoaded', function(e, module) {
console.log('module loaded', module);
console.log(mathController);
});
$scope.mathController = mathController;
$scope.simpleObj = simpleObj;
}
},
'footer': {
template: '<footer></footer>'
},
},
resolve: { // Any property in resolve should return a promise and is executed before the view is loaded
mathController: ['$ocLazyLoad', function($ocLazyLoad) {
// you can lazy load files for an existing module
return $ocLazyLoad.load('/assets/js/math.min.js')
}],
simpleObj: function(){
return {value: 'simple!'};
},
}
现在,console.log(mathController) 记录未定义,而 simpleObj 返回未定义。谁能解释一下?我该如何解决?这不是异步加载的问题,因为即使我在事件触发后登录控制台,它仍然是未定义的。我的假设是我应该能够在控制台中看到该功能?
解决方案
推荐阅读
- regex - 两个子字符串中的任何一个的正则表达式,但更喜欢较长的子字符串
- json - 使用 python 2.7 遍历 json 数组
- neo4j - search all nodes within particular radius with latitude and longitude in neo4j
- php - 下拉菜单和 PHP
- html - 使用 jQuery 检查复选框时如何添加和删除 CSS?
- kafka-consumer-api - Spring Cloud Stream 功能手册 致谢 - KafkaHeaders.ACKNOWLEDGMENT 不可用
- javascript - React:如何从另一个文件访问组件内定义的数组?
- javascript - Fetch API 不返回任何响应并导致任何错误
- css - 如何在反应引导中折叠卡片内的部分文本?
- python - 如何在熊猫应用中使用返回numpy数组的函数