【问题标题】:Angularjs $routeProvider jshint errorsAngularjs $routeProvider jshint 错误
【发布时间】:2016-07-05 20:50:26
【问题描述】:

我有这个角码

    (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'
                    }).
        }]);

    })();   

当我使用 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).

我看不到如何更改角度以通过 jshint

【问题讨论】:

  • 乍一看还不错,好像运行没问题……
  • 没有提供九个数字,所以很难提供帮助

标签: javascript angularjs jshint


【解决方案1】:
    when('/two',{
                    templateUrl: '../templates/two.html',
                    controller: 'twoController'
                }).

最后一个“.”应该是一个“;”相反,它应该看起来像

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-12
    • 2015-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多