Javascript 如何在Angularjs上获取当前模板?

Javascript 如何在Angularjs上获取当前模板?,javascript,angularjs,Javascript,Angularjs,我希望在Angularjs继续渲染模板之后,以字符串的形式获取当前html页面(例如) 目的是将此内容发送到我的服务器 .controller('MyCtrl', ['$scope', '$location', function ( $scope, $location) { // 1- get the current html content of my web page // 2- send it to my server }]) 感谢您的帮助您可以使用 angular.eleme

我希望在Angularjs继续渲染模板之后,以字符串的形式获取当前html页面(例如)

目的是将此内容发送到我的服务器

.controller('MyCtrl', ['$scope', '$location', function ( $scope, $location) {

 // 1- get the current html content of my web page

// 2- send it to my server 

}])

感谢您的帮助

您可以使用

angular.element('html').html()

之后,使用$http服务将数据发送回服务器。

您必须创建一个指令,在link函数中运行您的代码。在构建模板后调用link函数

指令:

test.directive("myDirective", function () {
    return function (scope, element, attrs) {
        scope.$watch("variable", function (value) {
            var val = value || null;
            if (val) {
                element('html').html();
            }
        });
    };
});
在HTML中

<body my-directive></body>

或可能是建议?我想将当前html页面发送到我的服务器。由于此页面已编译,格式良好(html+css),并已下载到用户计算机上。。。我想把它发送到我的服务器,我想重新使用它通过电子邮件发送给客户。瞧。