我在我的 app.config 块中尝试使用 $templateCache 时收到“angular.min.js:6Uncaught Error: [$injector:modulerr]”,如果我从 app.config 中删除 $templateCache 参数,那么我看不到任何错误。如果我错过了什么,请告诉我。提前致谢。
var app = angular.module("app", ['ui.router'], function () {
console.log('Application Initiated Successfully...');
})
.run(function ($templateCache, $http) {
console.log("app is running");
$http.get("Views/home2.html", { cache: true }).success(function (html) {
$templateCache.put("Test.html", html);
console.log($templateCache.get("Test.html"));
});
console.log($templateCache.info());
});
app.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', '$templateCache', function ($stateProvider, $urlRouterProvider, $locationProvider, $templateCache) {
$urlRouterProvider.otherwise("/");
$stateProvider
.state("/", {
url: "/",
templateUrl: "Views/home.html"
});
}]);
app.controller("indexController", ["$rootScope", "$scope", function ($rootScope, $scope) {
console.log('indexController');
$scope.message = "Hi lets get started...";
} ]);