【发布时间】:2015-04-23 07:48:42
【问题描述】:
我遇到了由 gulp-ng-annoate 生成的错误的问题。
错误信息是
错误:app.js:错误:由于解析错误而无法处理源代码
我发现另一个线程似乎与我有同样的问题,但该答案对我不起作用。 the other thread
这是我的 gulp 文件和我正在尝试执行任务的文件。
gulpfile.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'))
})
以及我尝试连接/ngAnnotate 的文件
module.js
angular.module('app', [])
posts.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
})
})
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)
}
}])
可能出了什么问题..?
【问题讨论】:
标签: javascript angularjs gulp mean-stack