2016-09-27 4 views
0

나는 내 편집기에 ngcomponent를 입력 할 때, 다음과 같은 구조로 확장, Atom에 대한 angular-js-styleguide-snippets을 사용하고 있습니다 :각도 구성 요소의 스타일 가이드

(function() { 
    'use strict'; 

    angular 
     .module('arroyo') 
     .component('intro', component); 

    /* @ngInject */ 
    function component() { 
     var settings = { 
      template: '<h1>test</h1>', 
      controller: Controller, 
     }; 

     return settings; 
    } 

    Controller.$inject = []; 

    /* @ngInject */ 
    function Controller() { 

    } 
})(); 

을하지만, 작동하지 않는 것 위의 코드를 사용하여. 콘솔 오류는 없지만 구성 요소 자체 (<intro></intro>)는 아무 것도 렌더링하지 않습니다. 주변을 둘러보고 난 후 아래 코드를 사용하면 예상대로 작동한다는 것을 알게되었습니다.

(function() { 
    'use strict'; 

    angular 
     .module('arroyo') 
     .component('intro', { 
      template: '<h1>test</h1>' 
     }); 
})(); 

첫 번째 코드 단편의 잘못된 점은 무엇입니까?

답변

1

당신과 같이 함수 구성 요소를 호출해야합니다

angular 
    .module('arroyo') 
    .component('intro', component()); 

새로운 구성 요소 방법은 실제로 당신이 그 개체를 반환 함수를 호출하여, 사용자가 설정을 제공하는 객체를합니다.

자세한 내용은 docs을 확인하십시오.