javascript - 未知提供者:attrsProvider <- attrs
问题描述
从我的子控制器访问 attrs 时出现此错误
> Unknown provider: attrsProvider <- attrs
这是我的代码:
var app = angular.module('plunker', []);
//parent controller
app.controller('MainCtrl', function($scope, $controller, $attrs ) {
//extending child controlller
angular.extend(this, $controller('MainCtrl2', {$scope: $scope}));
});
//child controller
app.controller('MainCtrl2', function($scope, $controller, $attrs) {
console.log($attrs)
});
但是从父控制器访问 attrs 工作正常...
解决方案
你也必须提供$attrs
。
angular.extend(this, $controller('MainCtrl2', {$scope: $scope, $attrs}));
推荐阅读
- android - 用于检查位置服务的 Android 后台服务是否打开或关闭
- python - 如何在python类中获取“条目”的信息
- mmenu - 防止mmenu在页面加载时自动打开
- python - 如果在文件打开的情况下在内部循环:解析时出现意外的 EOF
- jquery - 获取值形式数组字段名称
- javascript - 如何使用 jQuery Ajax 成功在我的 html 上打印邮递员返回的 JSON 数组?
- java - InputStream 的 Java 扫描器
- typescript - 生产模式下的 Mat Tab Change 事件
- spring-boot - SpringSecurity:认证成功后如何继续向 RestController 转发请求?
- wordpress - 注册 WP-Members 后如何自动登录用户?