저는 AngularJS를 배우는 중이고 똑같은 일을하는 여러 가지 방법을 찾고 있는데 어떤 것이 더 좋고 다른 옵션보다 하나의 옵션을 선택해야하는지 궁금합니다.Angularjs에 서비스를 삽입하는 올바른 방법은 무엇입니까?
내가 컨트롤러는 두 가지 방법으로 만들어 본 적이 :
app.controller('CustomersController', function ($scope, customersService) {});
및
app.controller('CustomersController', ['$scope', 'customersService', function ($scope, customersService) {}]);
분명히 두 번째 방법이 더 입력이지만, 처음 이상 그 방법을 사용하는 이점이 있습니까?
두 번째 옵션과 마찬가지로 컨트롤러를 작성한 후에 코드 'CustomersController. $ inject = ['$ scope ']'를 쓰거나 첫 번째 옵션에만 필요합니까? – callmekatootie