Angular未定义为Gulp.js

时间:2016-06-14 12:24:03

标签: javascript angularjs gulp

我仍然有这个错误没有定义Angular。我99.9999%肯定它与正确的道路没有相关的东西,但我没有线索。我无法解决它!这是我现在的文件夹结构:

bower_components/
node_modules/
app/
   components/
              home/
                   controller/
                              homeCtrl.js
                   css/
                         home.css
                   home.html

    shared/
           css/
           directives/
           filters/
           directives/
           sass/
           services/
assets/
    audio/
    debug/
    dist/
         app.min.js
         vendor.min.js
    lib/
    etc...

gulp/
   paths.js

gulpfile.js
index.html
etc....

由于某种原因,没有定义角度。

Gulpfile.js:

//Require Gulp
var gulp = require("gulp");
var ngAnnotate = require("gulp-ng-annotate");
var uglify = require("gulp-uglify");
var concat = require("gulp-concat");
var sourceMaps = require("gulp-sourcemaps");
var util = require('gulp-util');
var coffee = require("gulp-coffee")
var clean = require("gulp-clean");
var expect = require('gulp-expect-file');
var sass = require('gulp-sass');
var es = require('event-stream');
var ng_annotate = require('gulp-ng-annotate')


var base = 'app';
// var minifyCss = require('gulp-minify-css');

var paths = require("./gulp/paths");

//remove temporary directories like dist
gulp.task('clean', function() {
    return gulp.src('assets/dist', {read: false})
    .pipe(clean());
});

// combines all js files into one and create sourcemaps for them
gulp.task('scripts', function(done) {
    gulp.src(paths.js)
    .pipe(sourceMaps.init())
    .pipe(concat('app.min.js'))
    .pipe(ngAnnotate())
    .pipe(uglify().on('error', util.log))
    .pipe(sourceMaps.write('.'))
    .pipe(gulp.dest(paths.dest))
    .on('error', util.log)
    .on('end', done);
});



gulp.task('copy', function() {
  var files = ['bower_components/angular/angular.min.js'];
  return gulp.src(files)
    .pipe(expect(files))
});

gulp.task('watch', function() {
    gulp.watch(paths.js, ['scripts'])
});

gulp.task('scripts:vendor', function() {
   return gulp.src(paths.vendor_js)
        //  .pipe(concat(paths.vendor_js[0]))
         .pipe(concat('vendor.min.js'))
         .pipe(uglify().on('error', util.log))
         .pipe(gulp.dest(paths.dest));
});


gulp.task('serve', function() {

})


gulp.task('default', function() {
    console.log("running gulp");
});

吞/ Paths.js:

module.exports = {
    dest: 'assets/dist',
    js: [
        'app/app.module.js',
        'app/app.run.js',
        'app/shared/**/*.module.js',
        'app/shared/**/*.js',
        'app/components/**/*.js',
        'app/components/**/*.module.js'
    ],
    sass: ['app/shared/**/*.sass'],
    vendor_js: [
         'bower_components/jquery/dist/jquery.js',
         'bower_components/angular/angular.min.js',
         'bower_components/**/*.min.js',
         'assets/lib/svg-assets-cache/svg-assets-cache.js',
         'assets/lib/alertifyjs/build/alertify.min.js',
         'assets/lib/Recaptcha/googleRecaptchaAPI.js',
         'assets/lib/angular-screenfull/angular-screenfull.min.js',
         'assets/lib/screenfull/screenfull.min.js',
         'assets/lib/angular-selectize/angular-selectize.js'
    ],
    vendor_styles: [
        'bower_components/selectize/dist/css/selectize.css',
        'bower_components/font-awesome/css/font-awesome.min.css',
        'assets/lib/alertifyjs/build/css/alertify.css',
        'assets/lib/alertifyjs/build/css/themes/semantic.min.css',
        'bower_components/vex/css/vex.css',
        'bower_components/vex/css/vex-theme-flat-attack.css',
        'assets/lib/material-charts/material-charts.min.css'
    ]
};

的index.html:

<!DOCTYPE html>
<html lang="en" class="html_container">

<head>
    <meta charset="UTF-8">
    <!--<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">-->
    <meta name="viewport" content="width=1200">
    <title>Ng-Forum</title>

    <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css" />
    <link rel="stylesheet" href="assets/lib/alertifyjs/build/css/alertify.css" />
    <link rel="stylesheet" href="assets/lib/alertifyjs/build/css/themes/semantic.min.css" />
    <link rel="stylesheet" href="bower_components/vex/css/vex.css" />
    <link rel="stylesheet" href="bower_components/vex/css/vex-theme-flat-attack.css" />
    <link rel="stylesheet" href="https://cdn.rawgit.com/amanuel2/MathGame/master/chartjs/material-charts.min.css" type="text/css" />
    <link rel="stylesheet" href="bower_components/angular-material/angular-material.css" />
    <link rel="icon" href="favicon.ico">

</head>

<body ng-app="ForumApp">
    <div ui-view></div>
    <!--<script type="text/javascript" src="https://code.angularjs.org/1.4.9/angular.js"></script>-->
    <script type="text/javscript" src="assets/dist/vendor.min.js"></script>
    <script type="text/javascript" src="assets/dist/app.min.js"></script>
</body>

</html>

这里的帮助将非常感谢!顺便说一下我在Cloud9IDE上工作所以如果我们能在那里修复它,它会很快而且太棒了! https://ide.c9.io/amanuel2/ng-fourm

1 个答案:

答案 0 :(得分:0)

原因是我误导了javascript:

<script type="text/javscript" src="assets/dist/vendor.min.js"></script>

很难找到,因为,简单的东西可以完全让你失望!