缩小后,角度路线不起作用

时间:2017-06-05 07:34:24

标签: javascript angularjs gulp

我正在使用gulp来修改minifiy angular js文件,以下内容与gulp进行了修改,最终文件在libs.js

中输出
var files = [
    'node_modules/angular/angular.js',
    'node_modules/angular-route/angular-route.js'
]

问题是角度布线在minfication之后不起作用

route.config(['$routeProvider', function($routeProvider) {
    $routeProvider.
    when('/test', {
        templateUrl:'app/test.html',
        activetab:'emp',
        controller:'WelcomeController'
    }).
    when('/next',{
        templateUrl:'app/next.html',
        activetab:'emp',
        controller:'WelcomeController'
    })
        .otherwise({ redirectTo: '/next'})
}]);

HTML

<body ng-app="main" >
    <a href="#test">test</a>
         <div ng-view></div>
    </body>

然而,当我包含CDN链接而不是minfied文件时,一切正常

 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js" ></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular-route.js" ></script>

更新

Gulp minfication任务

var files = [
    'node_modules/angular/angular.js',
    'node_modules/angular-route/angular-route.js'
]

    gulp.task('libs', function () {
        return gulp.src(files)
            .pipe(concat('libs.js'))
            .pipe(gulp.dest('resources/assets/build'))
            .pipe(ngAnnotate())
            .pipe(uglify({
                mangle:false
            }))
            .pipe(gulp.dest('public/js'));

    });

更新

单击链接时,相应的控制器可以正常工作但视图未加载

0 个答案:

没有答案