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);
	});

 

posted @ 2017-05-16 10:56  居无常  阅读(989)  评论(0编辑  收藏  举报