我遇到了使用gulp-ng-annoate生成的错误的问题。
错误消息是
错误:应用程序.js:错误:由于解析错误,无法处理源
我发现了另一个线程,它似乎与我有同样的问题,但该答案对我不起作用。另一个线程
这是我的gulp文件和我尝试执行任务的文件。
古尔普文件.js
var gulp = require('gulp')
var concat = require('gulp-concat')
//var uglify = require('gulp-uglify')
var ngAnnotate = require('gulp-ng-annotate')
gulp.task('js', function(){
gulp.src(['ng/module.js', 'ng/**/*.js'])
.pipe(concat('app.js'))
.pipe(ngAnnotate())
//.pipe(uglify())
.pipe(gulp.dest('assets'))
})
和我正在尝试连接/ng注释的文件
模块.js
angular.module('app', [])
帖子.ctrl.js
angular.module('app')
.controller('PostCtrl', function($scope, PostsSvc){
$scope.addPost = function(){
if ($scope.postBody){
PostsSvc.create({
username: 'dickeyxxx',
body: $scope.postBody
}).success(function(post){
$scope.posts.unshift(post)
$scope.postBody = null
})
}
}
PostsSvc.fetch().success(function(posts){
$scope.posts = posts
})
})
帖子.svc.js
angular.module('app')
.service('PostsSvc', ['$http', function ($http){
this.fetch = function(){
return $http.get('/api/posts')
}
this.create = function(post){
return $http.post('/api/posts', post)
}
}])
可能出了什么问题..?
错误在于你放了一个.
而不是一个,
来分隔对象。
另外,不要忘记结束线路;
。