angularjs异步请求html并编译

// 异步加载模板并编译
$templateRequest("views/common/test.html").then(function(html) {
		// Step 1: parse HTML into DOM element
		var template = angular.element(html);
		// Step 2: compile the template
		var linkFn = $compile(template);
		// Step 3: link the compiled template with the scope.
		var element = linkFn($scope);
		// Step 4: Append to DOM (optional)
		angular.element("#test").append(element);
	});
原文地址:https://www.cnblogs.com/guxingzhe/p/6860255.html