HEROJOON 블로그(히로블)

AngularJS 1.x route에 param 설정하기 본문

Frontend

AngularJS 1.x route에 param 설정하기

herojoon 2020. 3. 22. 21:08
반응형

// route에 param 설정
app.config(['$routeProvider', function($routeProvider) {
    $routeProvider
        .when('/', {
            templateUrl: 'main.html',
            controller: 'MainController'
        })
        .when('/samplepage/:sampleId', {
            templateUrl: 'samplepage.html',
            controller: 'SampleController'
        })
        .otherwise({
            redirectTo: '/'
        });
}]);

// SampleController.js에서 넘겨진 Param 가져오기
$scope.sampleId = $routeParams['sampleId'];

반응형
Comments