m hadadi
m hadadi

Reputation: 949

when use ng-include inside of ui-view get error

I using Angular.js for my application but when i use ng-include inside of ui-view like below I get this error:

Error: e is null .after/<@http://localhost/vb-asli/js/angular.min.js:152:228 r@http://localhost/vb-asli/js/angular.min.js:7:288

And my code is like this:

<div ui-view>
    <div  ng-include="'partials/menuPreview.html'">
    </div>
</div>

Upvotes: 0

Views: 1575

Answers (1)

JoseM
JoseM

Reputation: 4302

That's because you aren't supposed to put any child elements directly inside a ui-view.

I think you are misunderstanding how ui-view is supposed to be used. From the docs here and here there is no mention of putting child elements directly inside of a ui-view.

I haven't looked into the code deeply enough but I can see that if you do put a ng-include inside of ui-view, the ng-include directly fails because the parent node is null, which leads me to believe that ui-view is clearing/removing any contents inside the element (or doing something similar). And it makes sense it would do that because that is what it will be doing when switching routes/states.

Upvotes: 3

Related Questions