未解决的问题:ngRepeat如何在拼接字符串模板中使用?

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/rencaishigepi/article/details/82625605

这是我写的一个例子,但是报错

<!DOCTYPE html>
<html ng-app="app">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>ngRepeat</title>
    <link rel="stylesheet" href="">
</head>
<body ng-controller="ctrlApp">

</body>
<script src="../../lib/js/angular.js"></script>
<script>
    var app = angular.module('app', []);
    app.controller('ctrlApp', ['$scope', '$compile', function($scope, $compile) {
        $scope.a = [1,2,3,4];
        var html = '';
        html += '<div ng-repeat="a in as">{{a}}</div>';
        var temp = $compile(html)($scope);
        document.body.innerHTML = temp;
    }]);
</script>
</html>

这里写图片描述
不知道怎么解决?

猜你喜欢

转载自blog.csdn.net/rencaishigepi/article/details/82625605
今日推荐