我正在使用angular
构建gulp
应用程序。我的静态index.html
工作正常。
但是angular
应用根本没有响应。我也没有收到任何错误。我想,模块本身没有加载到这里。
我不知道我在这里犯了什么错。有人想出来吗?
我的gulpfile.js
:
var paths = require('./gulp/paths'),
gulp = require('gulp'),
args = require('yargs').argv,
fileSytems = require('file-system'),
ngConstant = require('gulp-ng-constant'),
rename = require('gulp-rename')
browserSync = require('browser-sync').create();
var ENV = args.env || "mock";
gulp.task('constants', function () {
var myConfig = require('./envs.json');
var envConfig = myConfig[ENV];
return ngConstant({
name: "app.constants",
constants: envConfig,
stream: true
})
.pipe(rename('constants.config.js'))
.pipe(gulp.dest('source/app'));
});
gulp.task('browser-sync', function(){
browserSync.init({
server:{
baseDir : './source'
},
port : 9999
})
})
gulp.task('default', ['constants', 'browser-sync'], function(){
gulp.watch( ['source/app/components/*.js']);
gulp.watch( ['source/**/*.html'], browserSync.reload);
});
我的角度文件index.module.js
:(作为测试)
(function(){
'use strict';
angular.module('myApp.controllers', []);
angular.module('myApp.directives', []);
var modules = [ 'myApp.controllers', 'myApp.directives' ];
angular.module('myApp', modules);
angular.module('myApp.controllers')
.controller('mainController', ['$scope', function($scope){
$scope.name = "World";
}]);
})();
我的index.html
文件:
<!DOCTYPE html ng-app="myApp">
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<!-- libraries -->
<script src="./lib/angular/angular.js"></script>
<title>My App Proto</title>
<link rel="stylesheet" href="">
</head>
<body ng-controller="mainController">
<h2>My Application goes here!</h2>
<h2>{{ 2 + 2 }}</h2> //i am not getting any result! error too
<img src="" alt="">
<!-- scripts -->
<script src="./app/index.module.js"></script>
<!-- <script src="./app/components/mainController.js"></script> -->
</body>
</html>
我正在为gulp运行以启动我的应用程序的命令是:'gulp'(默认)
有人帮我吗?