Angularjs在同一行ng-repeat中失去了范围

时间:2014-10-30 23:20:14

标签: angularjs templates angularjs-ng-repeat

我无法替换ng-include中模板标记内的{{path}}。如果我将标签放在模板内的任何其他地方工作完美,但是我需要在include-ng中工作以获得基本路径。任何人都有自己的想法。

带MVC的Html

 <div ng-controller='menuCtrl'>
                <nav id="menu">
                    <ul>
                        <li ng-repeat="item in itens" ng-include="'@(ViewBag.path)Areas/System/scripts/templates/menu.html'" repeat-done></li>
                    </ul>
                </nav>
 </div>

App.js

var myApp = angular.module('mobsupplyApp', []).directive('repeatDone', function () {
    return function (scope) {
        if (scope.$last === true) {
            setTimeout(function () {
                $("#menu").jarvismenu();
            });
        }
    };
});

myApp.controller('menuCtrl', ['$scope', '$http', function ($scope, $http) {
    $http.get(path + "api/menu").success(function (data, status) {
        $scope.itens = data;
        $scope.path = path;
    });
}]);

Template.html

<a href="{{ item.url }}" title="{{ item.description }}"><i class="fa fa-lg fa-fw {{ item.image }}"></i> <span class="menu-item-parent">{{ item.description }}</span></a>

<ul ng-if="item.itens">
    <li ng-repeat="item in item.itens" ng-include="'{{ path }}Areas/System/scripts/templates/menu.html'"></li>
</ul>

0 个答案:

没有答案