// 异步加载模板并编译 $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); });