如何将scope.value作为HTML附加?

时间:2014-11-27 15:38:12

标签: javascript html angularjs angularjs-scope

我目前正在编写一个AngularJS应用程序,并且我想将$ scope下的值作为HTML标记值而不是常规值追加或使其值。

HTML:

<div gridster="gridsterOptions">
        <ul>
            <li gridster-item="widget" ng-repeat="widget in dashboard.widgets"  class="main-dashboard-container">
                <div class="box" ng-controller="CustomWidgetCtrl">
                    <div class="box-header main-dashboard-header">
                        <h4>{{ widget.name }}</h4>
                        <div class="box-header-btns pull-right">
                            <a title="settings" ng-click="openSettings(widget)"><i class="glyphicon glyphicon-cog"></i></a>
                            <a title="Remove widget" ng-click="remove(widget)"><i class="glyphicon glyphicon-trash"></i></a>
                        </div>
                    </div>
                    <div class="box-content main-dashboard-content">{{ widget.content }}</div>
                </div>
            </li>
        </ul>
    </div>

AngularJS代码:

$scope.dashboards = {
            '1': {
                id: '1',
                name: 'Home',
                widgets: [{
                    col: 0,
                    row: 0,
                    sizeY: 1,
                    sizeX: 1,
                    name: "URL Filter",
                    content:'<div class="table-responsive " ng-controller="URLFilterCategoriesController as viewAll"><table class="table table-hover"><thead><tr><td>Categories</td><td>Hits</td></tr></thead><tbody><tr ng-repeat="urlfil in viewAll.urlfiltercat"><td>{{urlfil.category}}</td><td>{{urlfil.hit}}</td></tr></tbody></table></div>'
                }, {
                    col: 2,
                    row: 1,
                    sizeY: 1,
                    sizeX: 1,
                    name: "Widget 2"
                }]
            },

正如你在AngularJS代码中看到的那样,我添加了一系列html代码,我希望它在我的HTML代码中作为HTML附加/添加。谢谢!

1 个答案:

答案 0 :(得分:0)