저는 AngularJS에 완전히 익숙하며 과정을 따라이 프레임 워크를 "배우기 시작했습니다". 나는이 페이지의 상단에있는이 개 스크린 캐스트를 보았다 :컨트롤러의 범위 변수 초기화
https://github.com/curran/screencasts/tree/gh-pages/introToAngular
을 모두 스크린 캐스트를보고 내가 어떤 컨트롤러와 함께 작동하도록 시도 내 자신의 간단한 각도 응용 프로그램을 만들려고 예제의 일부를 조사 후.
Index.html을 나는 AI가 didn를 알아 냈어 컨트롤러 범위에 VARA을 결합하는 시도 후
<html ng-app="WIMT">
<head>
<title>trying out angularJS</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery.min.js"></script>
<script type="text/javascript" src="../bower_components/angular/angular.min.js"></script>
<script type="text/javascript" src="../JS/app.js"></script>
</head>
<body>
<div ng-controller="controllerA as a">
{{a.varA}}
</div>
<div ng-controller="controllerB as b">
{{b.varB}}
</div>
<div ng-controller="controllerC as c">
{{c.varC}}
</div>
</body>
</html>
JS
(function() {
var app = angular.module('WIMT',[]);
app.controller('controllerA',function($scope,$http){
$scope.varA = "A";
});
app.controller('controllerB',['$scope',function($scope) {
$scope.varB = "B";
}
]);
app.controller('controllerC',function($scope, $http) {
var reg = this;
reg.varC = "C";
});
})();
: 이제 다음 코드가 일하지 않고 인터넷에서 해결책을 찾았습니다. 나는 몇 가지 다른 방법 (B & C)을 발견했다. C 옵션 만 작동하고 html을 실행할 때 C가 표시됩니다. 두 A & B는 아무것도 표시하지 않습니다.
이 예제에서 옵션 A와 B가 작동하지 않는 이유는 무엇입니까?
Btw를 사용하면 자체 실행 익명 기능으로 각도 앱을 둘러 쌀 필요가 없습니다. – Kyle