我仍然在尝试理解angular周围的前端东西。我正在使用yeaman生成器来创建angular / gulp项目。
这就是我的问题:
PS P:\projects\trax> gulp test
[19:35:22] Using gulpfile P:\projects\trax\gulpfile.js
[19:35:22] Starting 'scripts'...
[19:35:30]
P:\projects\trax\src\app\components\head\user\menu.dialog.controller.js
7:9 error "vm" is defined but never used no-unused-vars
10:5 error You should not set properties on $scope in controllers. Use controllerAs syntax and add data to "this" angular/controller-as
14:5 error You should not set properties on $scope in controllers. Use controllerAs syntax and add data to "this" angular/controller-as
18:5 error You should not set properties on $scope in controllers. Use controllerAs syntax and add data to "this" angular/controller-as
✖ 4 problems (4 errors, 0 warnings)
[19:35:30] all files 14.79 kB
[19:35:30] Finished 'scripts' after 7.75 s
[19:35:30] Starting 'test'...
28 11 2017 19:35:33.855:WARN [proxy]: proxy "\base\src\assets\" normalized to "\base\src\assets\/"
28 11 2017 19:35:35.077:WARN [watcher]: Pattern "P:/projects/trax/src/**/*.mock.js" does not match any file.
PhantomJS 1.9.8 (Windows 8 0.0.0): Executed 1 of 1 SUCCESS (0.032 secs / 0.34 secs)
[19:35:38] Finished 'test' after 8.1 s它可以运行,但我想防止出现线损警告。多么?我理解这条消息,但是如果我像前面提到的那样进行替换,我只会得到错误。
这是前面提到的文件中的代码。
angular
.module('trax')
.controller('MenuDialogController', MenuDialogController);
function MenuDialogController($scope, $mdDialog) {
var vm = this;
$scope.close = function close(){
$mdDialog.hide();
}
$scope.cancel = function cancel(){
$mdDialog.hide();
}
$scope.ok = function ok(){
alert('ok clicked');
$mdDialog.hide();
}
}这是打开对话功能userController($scope,$mdDialog,$document)的控制器{
var vm = this;
vm.user = {
name: 'Test User'
};
vm.showMenu = function showMenu(ev){
$mdDialog.show({
controller: "MenuDialogController",
controllerAs: 'vm',
templateUrl: 'app/components/head/user/menu.dialog.html',
parent: angular.element($document.body),
targetEvent: ev,
clickOutsideToClose:true,
fullscreen: $scope.customFullscreen // Only for -xs, -sm breakpoints.
});
};
}
}如果我将前面提到的方法更改为$scope.close = ...我在LINT中阻止了这个警告,但是dialogs方法不需要更多的工作。
有什么提示吗...?关于n00n
https://stackoverflow.com/questions/47538798
复制相似问题