Javascript ReferenceError:左侧的赋值无效(app.js:41:27)&;没有显示任何内容

Javascript ReferenceError:左侧的赋值无效(app.js:41:27)&;没有显示任何内容,javascript,angularjs,angularjs-module,Javascript,Angularjs,Angularjs Module,启动服务器后,我导航到“localhost:8000”。我看到的唯一一件事是,对于行$scope.userLogin()=function(userSrv){ index.html <!DOCTYPE html> <!--[if lt IE 7]> <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> <!--[if IE 7]

启动服务器后,我导航到“localhost:8000”。我看到的唯一一件事是,对于行
$scope.userLogin()=function(userSrv){

index.html

<!DOCTYPE html>
<!--[if lt IE 7]>      <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html lang="en" ng-app="myApp" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" ng-app="myApp" class="no-js"> <!--<![endif]-->
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>My AngularJS App</title>
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/normalize.css">
  <link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/main.css">
  <link rel="stylesheet" href="app.css">
  <script src="bower_components/html5-boilerplate/dist/js/vendor/modernizr-2.8.3.min.js"></script>
</head>
<body>


<!--[if lt IE 7]>
    <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->

<div ng-view></div>


<!-- In production use:
<script src="//ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js"></script>
-->
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="app.js"></script>
<script src="services/services.js"></script>
<script src="components/version/version.js"></script>
<script src="components/version/version-directive.js"></script>
<script src="components/version/interpolate-filter.js"></script>
</body>
</html>
app.js

    'use strict';

// Declare app level module which depends on views, and components
angular.module('myApp', [
    'ngRoute'
])
.constant('STORAGE_NAME', 'USER_CARS')
.config(configStorage)
.config(configRoutes)

.controller('carsCtrl', ['$scope', '$http', 'carsService',
    function($scope, $http, carsService) {
        alert("cars view");

        $http.get('cars/cars.json')
            .success(function(data) {

                $scope.cars = data;

                $scope.addCar = function(id, title, color, description, image) {
                    carsService.addUserCar(id, title, color, description, image);
                };

            })
            .error(function() {
                alert("can not get data from cars.json");
            });
    }
])

.controller('homeCtrl', [

    function() {
        alert("home view");
    }
])

.controller('loginCtrl', ['userSrv', '$scope',
    function (userSrv, $scope) {
        alert("login view");
        $scope.userLogin() = function(userSrv){
            userSrv.login();
        }

    }
])

.controller('profileCtrl', ['$scope', 'carsService',
    function($scope, carsService) {
        alert("profile view");
        $scope.userCars = carsService.getCars();


    }
]);

function configStorage(storageProvider, STORAGE_NAME){
  console.log(storageProvider);
  storageSrvProvider.configStorageName(STORAGE_NAME);
}

function configRoutes($routeProvider) {
        $routeProvider

        .when('/cars', {
            templateUrl: 'views/cars.html',
            controller: 'carsCtrl',
            secure: true
        })

        .when('/profile', {
            templateUrl: 'views/profile.html',
            controller: 'profileCtrl',
            secure: true
        })

        .when('/home', {
            templateUrl: 'views/home.html',
            controller: 'homeCtrl',
            isLogin: false
        })

        .when('/login', {
            templateUrl: 'views/login.html',
            controller: 'loginCtrl',
            secure: false
        })



        .otherwise({
            redirectTo: '/home'
        });
    }

var appRun = function($rootScope, $location, $userService) {
    $rootScope.on('$routeChangeStart', function(event, next) {
        if (next.secure && !userService.checkLoginUser()) {
            $location.path('/login');
        }
    });
};

基本上,你是在两次声明你的应用程序,这是在刷新旧的应用程序组件。在这里,你已经从
app.js
定义了你的应用程序模块
myApp
,但是从
service.js
service
组件修改为
myApp
模块,你已经使用过
angular.module('myApp',[])
重新初始化你的应用程序。你必须在控制台内有getting
$injector
错误

代码

'use strict';
angular.module('myApp')
.service('carsService', function () {

不能为函数调用赋值,如下所示:

    $scope.userLogin() = function(userSrv){
        userSrv.login();
    }
我想应该是的

    $scope.userLogin = function(userSrv){
        userSrv.login();
    }

错误也应该显示哪一行,为什么不检查一下呢?ReferenceError:invalid assignment left-side app.js:41:27您应该能够查看行号并找出问题所在。
$scope.userLogin()=function(userSrv){
应该是
$scope.userLogin=function(userSrv){
根据@Pankaj更改代码后,我获取未知提供程序“错误:[$injector:modulerr]未能实例化模块myApp,原因是:[$injector:unpr]:storageProvider”@愤怒1888因为你的应用程序中没有
存储
提供商..我认为应该是
存储SRV
太好了!我已经更改了。存储到存储SRV&面临另一个问题。当单击汽车的“添加”按钮时,我看到“错误:未定义CARSRV”你必须确保你应该注入carsService而不是carsSrvGreat Thank!现在我希望我能成功地验证和重定向用户
    $scope.userLogin = function(userSrv){
        userSrv.login();
    }