각도 버전 1.5.8. 여기 AngularJS는 구성 요소의 컨트롤러를 정의합니다.
내 HTML 페이지의 코드를 단순화 :<body>
<div ng-app="identicaApp">
<div id="navbar_wrapper">
<navbar-component></navbar-component>
</div>
<div id="register_player_wrapper">
<register-player></register-player>
</div>
</div>
<script src="/static/angular/identica/identica.js"></script>
<script src="/static/angular/identica/common.js"></script>
<script src="/static/angular/identica/navbar/navbar.module.js"></script>
<script src="/static/angular/identica/navbar/navbar.component.js"></script>
<script src="/static/angular/identica/registration/register_player/register-player.module.js"></script>
<script src="/static/angular/identica/registration/register_player/register-player.component.js"></script>
</body>
Navbar를 올바르게로드되지만, 레지스터 플레이어 구성 요소는 오류없이, 전혀로드되지 않습니다. 내가 오류와 각도 폭포
<div id="navbar_wrapper" ng-controller="RegisterPlayerController">
또는
<navbar-component ng-controller="RegisterPlayerController"></navbar-component>
내부에 있지만,이 경우에는 컨트롤러를 정의하기 위해 노력했습니다
angular.module('identicaApp.registration.player', ['identicaApp.common'])
.component('registerPlayer', {
templateUrl: '/static/angular/identica/registration/register_player/register_player.html',
controller: ['$resource', '$http', 'geolocationProvider', function RegisterPlayerController($resource, $http, geolocationProvider) {
// logic here
}]
});
: 여기 레지스터 player.component.js의 코드 Argument 'RegisterPlayerController' is not a function, got undefined
. 어떤 도움을 주셔서 감사합니다.
왜 'ng-controller'를 통해'component's' 컨트롤러를 추가하려고합니까? 나는 무엇을 위해 의미합니까? 외부에 왜 그것을 추가해야합니까? – Kindzoku
@Kindzoku 그냥 작동하도록 뭔가를하려합니다 – Compadre
'controllerAs'를 사용하고'register_player.html'을 사용하십시오 – taguenizy