Angular JS의 새로운 기능이므로 내게 맨손입니다. 이 컨트롤러는 잘 작동합니다 : 나는 그것이 자신의 JS 파일의 컨트롤러를 만들 때 더 이상 작동하지 않습니다Angular JS - JS 파일에서 조절기로드하기
function airlineRouter($routeProvider) {
$routeProvider
.when('/',
{
templateUrl:"partials/destinations.html",
controller: function($scope) {
$scope.setActive('destinations');
} //end controller
});
} //end airlineRouter
.
function airlineRouter($routeProvider) {
$routeProvider
when('/',
{
templateUrl:"partials/destinations.html",
controller: "DestinationsCtrl"
});
} //end airlineRouter
내 컨트롤러 파일 내 'app.js'파일이있는 동일한 폴더는 '루트 /의 JS/컨트롤러/destinations.js'에있는이처럼. 전체 'app.js'파일은 다음과 같습니다
angular
.module('airline', ['ngRoute'])
.config(airlineRouter);
function airlineRouter($routeProvider) {
$routeProvider
.when('/',
{
templateUrl:"partials/destinations.html",
controller: "DestinationsCtrl"
}
);
} //end airlineRouter
내 전체 컨트롤러 JS 파일은 다음과 같다 :
function DestinationsCtrl($scope) {
$scope.setActive('destinations');
} //end DestinationsCtrl
왜 것이 혀의 I와 같은 함수 이름으로 나의 컨트롤러의 부하 뭐하는거야? 혀의 파일이 효과가있는 것 같습니다. 내 것이 아니야. 도움과 감사!
편집 : 인수 'DestinationsCtrl'없는 기능입니다
정의되지 않은 편집이있어 : [AREQ NG :]가 : 오류 : 콘솔 로그이 표시 나는 '중첩 스코프'불렀다 작업 된 혀, 경우 누구에게 내가 뭘하려고하는지 더 잘 알게 해줍니다.
로딩 순서는 무엇입니까? – charlietfl
하나의 제안은 'app.controller ('DestinationsCtrl ', function ($ scope) ...' – charlietfl
oops ...'var app의 'var app = module ('항공사 '...' = angular.module ('항공사'... 왼쪽으로 '각을 치지 않음' – charlietfl