programing

ng-view의 "Controller as" 구문

iphone6s 2023. 4. 2. 10:05
반응형

ng-view의 "Controller as" 구문

어떻게 하면 좋을까요?Controller as와 조합한 구문ngRoute할 수 없기 때문에ng-controller="Controller as ctrl"

를 사용할 수 있습니다.controller as에서 컨트롤러를 지정하는 경우의 구문$routeProvider배열.

예.

$routeProvider
    .when('/somePath', {
        template: htmlTemplate,
        controller: 'myController as ctrl'
    });

또는 새로운 디렉티브를 작성할 때와 같은 컨트롤러 할당을 지정할 수 있습니다.controllerAs.

    $routeProvider
        .when('/products', {
            templateUrl: 'partials/products.html',
            controller: 'ProductsController',
            controllerAs: 'products'
        });

언급URL : https://stackoverflow.com/questions/23861101/controller-as-syntax-for-ng-view

반응형