cari

Rumah  >  Soal Jawab  >  teks badan

angular.js - angularjs出错,不能注入...

js:

var app = angular.module('MyTest', ['ng-pagination']);


app.factory("myService", ['$http', function ($http) {

    return {

        loadDatas: function (pageNo) {

            console.log(pageNo);

            var args = {"pageNo": pageNo};
            var url = "loadDatas.req";

            return $http({
                method: 'POST',
                data: args,
                url: url
            }).success(function (response) {

                return response;

            }).error(function (response, status) {

                alert(status + response);

            });

        }
    };

}]);


app.controller('myControllers', ["$Scope", "myService", function ($Scope, myService) {

    function getAllDatas(pageNo) {

        console.log(pageNo);

        myService.loadDatas(pageNo).then(function (result) {

            $Scope.datas = result.data.content;
            $Scope.totalItems = result.data.totalElements;
            $Scope.pageCount = result.data.totalPages;

        });

    }

    getAllDatas(1);


}]);

jsp:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>$Title$</title>
    <link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/css/ng-pagination.min.css">
</head>
<body ng-app="MyTest" ng-controller="myControllers">

<p>

    <p>二级菜单联动</p>

</p>



</body>

<script src="../../js/jquery-1.12.2.min.js"></script>
<script src="../../js/angular1.5.3.min.js"></script>
<script src="../../js/my.js"></script>
<script src="../../js/ng-pagination.min.js"></script>

</html>

出错了:

angular1.5.3.min.js:116 Error: [$injector:unpr] http://errors.angularjs.org/1.5.3/$injector/unpr?p0=%24ScopeProvider%20%3C-%20%24Scope%20%3C-%20myControllers

求指点迷津!!!

滿天的星座滿天的星座2744 hari yang lalu479

membalas semua(2)saya akan balas

  • PHP中文网

    PHP中文网2017-05-15 17:03:59

    • myControllers dalam $Scope dalam huruf kecil S

      Kebergantungan
    • angular hendaklah diperkenalkan di hadapan js yang anda tulis ng-pagination

    • balas
      0
  • ringa_lee

    ringa_lee2017-05-15 17:03:59

    Jangan gunakan perpustakaan min semasa membangun, kerana maklumat tidak lengkap

    balas
    0
  • Batalbalas