简体   繁体   English

AngularJS $ routeProvider jshint错误

[英]Angularjs $routeProvider jshint errors

I have this angular code 我有这个角度代码

    (function() {
        'use strict';

        var sampleApp = angular.module('MyApp', [
            'ngRoute',
            'MyApp.controllers.Main'
        ]);

        sampleApp .config(['$routeProvider',
            function($routeProvider){
                $routeProvider.

                    when('/',{
                        templateUrl: '../templates/home.html',
                        controller: 'homeController'
                    }).

                    when('/one',{
                        templateUrl: '../templates/one.html',
                        controller: 'oneController'
                    }).

                    when('/two',{
                        templateUrl: '../templates/two.html',
                        controller: 'twoController'
                    }).
        }]);

    })();   

and when I use jshint I get these errors. 当我使用jshint时,出现这些错误。

    src/app/app.js: line 27, col 5, Expected an identifier and instead saw '}'.
    src/app/app.js: line 27, col 5, Expected an assignment or function call and instead saw an expression.
    src/app/app.js: line 27, col 6, Missing semicolon.
    src/app/app.js: line 27, col 6, Expected an identifier and instead saw ']'.
    src/app/app.js: line 27, col 6, Expected an assignment or function call and instead saw an expression.
    src/app/app.js: line 27, col 7, Missing semicolon.
    src/app/app.js: line 27, col 7, Expected an identifier and instead saw ')'.
    src/app/app.js: line 27, col 7, Expected an assignment or function call and instead saw an expression.
    src/app/app.js: line 29, col 2, Expected ']' to match '[' from line 9 and instead saw ')'.
    src/app/app.js: line 29, col 5, Expected ')' and instead saw ';'.
    src/app/app.js: line 29, col 6, Missing semicolon.
    src/app/app.js: line 1, col 13, Unmatched '{'.
    src/app/app.js: line 29, col 10, Unrecoverable syntax error. (100% scanned).

I cant see how to change the angular to pass jshint 我看不到如何更改角度以通过jshint

    when('/two',{
                    templateUrl: '../templates/two.html',
                    controller: 'twoController'
                }).

The last "." 最后 ”。” should be a ";" 应该是“;” instead so it should look like 相反,它应该看起来像

     when('/two',{
                    templateUrl: '../templates/two.html',
                    controller: 'twoController'
                });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM