Tôi đang làm việc trên hướng dẫn góc cạnh và tôi đang gặp vấn đề khi bắt đầu. Tải mô-đun myApp ném lỗi. Như đã giải thích trong hướng dẫn, đây là một trong ba cách để tạo bộ điều khiển.
Dưới đây là màn hình in từ hướng dẫn tôi đang làm việc trên: Lỗi không bắt buộc: Mô-đun 'myApp' không khả dụng! (AngularJS)
Khi tôi làm mới trang web tôi nhận được lỗi này trong Chrome console:
Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:nomod] Module 'myApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
này được tập tin HTML của tôi
<html ng-app="myApp">
<head>
</head>
<body>
<h1>Hello world!</h1>
<div ng-controller="MainController">
{{ 2+2 }}
<br>
{{ val }}
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js"></script>
<script src="app.js">
</body>
</html>
Đây là tệp app.js của tôi
var myApp = angular.module('myApp', []);
var MainController = function($scope){
$scope.val = "Main controller variable value"
}
Vì vậy, vấn đề của tôi là gì? Tôi không thể hiểu được.
Cảm ơn bạn trước
Đôi mắt đẹp .. +1 sir –
bạn đã đúng! đôi mắt thực sự tốt đẹp .. cảm ơn bạn! –
:) cảm ơn các bạn .. – PSL