2013-03-12 2 views
0

제품 관리 관리 사이트를 각을 사용하도록 변환 중입니다 - 내 관리자 페이지의 모든보기 (제품 목록, 상세보기, 편집 등)가 모두보기로 표시됩니다. 거기에서 모두 좋다. 그러나 각 제품에 대한 정보를 인쇄 할 수있는 링크가 있습니다. 현재 다른 외부 템플릿과 다른 제품을 사용하고 있습니다.각도로 외형 템플릿 변경

어떻게 처리할까요?

앱 내 관리 목록에서

angular.module('myApp', []). 
    config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { 

    // all routes but print use an index.html template 
    $routeProvider. 
     when('/', { 
     templateUrl: '/partials/order/manage.html', 
     controller: ManageOrderCtrl 
     }). 
     when('/order/:id', { 
     templateUrl: '/partials/order/_view.html', 
     controller: ViewOrderCtrl 
     }). 
     when('/order/edit/:id', { 
     templateUrl: '/partials/order/_edit.html', 
     controller: ViewOrderCtrl 
     }). 
     // I want this link to not use the same outer template (i.e. something like printer.html as well as use custom headers) 
     when('/order/print/:id', { 
     templateUrl: '/partials/order/_print.html', 
     controller: PrintOrderCtrl 
     }). 
     otherwise({ 
     redirectTo: '/' 
     }); 
    $locationProvider.html5Mode(true); 
    }]); 

:

<div ng-repeat="order in orders"> 
    <a title="Print product sheet" href="/order/print/{{ order._id }}"></a> 
</div> 

는 지금이 _print.html 야기은 다른 같은 NG 뷰 내부에 위치한다. 새로운 창에서 열어보고 싶습니다. 방금 새 앱을 만들까요?

답변

0

서비스를 작성할 수 있으며 해당 서비스 내부에서 html을 가져 오기 위해 ajax 호출을 수행 할 수 있습니다. 이제 HTML의 뜻이 포함되어 자리 즉, {{}}, 당신은 대체 할 템플릿 라이브러리 (예를 들어, 콧수염.)가 필요하므로 그 {{}} 실제 데이터와

factory('print', ["$window", function($window) { 
/* service in charge of printing */ 
return function(templateUrl, context) { 
    /* send a GET request to templateUrl for template, render the template with context 
    * and open the content in a new window. 
    */ 
    $.ajax({ 
     url: templateUrl, 
     async: false, //otherwise the popup will be blocked 
     success: function(html) { 
      var template = html.replace('<!DOCTYPE html>\n<html lang="en">\n', '').replace("</html>", ''), 
       output = Mustache.render(template, context); 
      $window.open().document.documentElement.innerHTML = output; 
     } 
    }); 
}; 

}]);