Ng-if, Ng-switch And Dynamic Ng-include Not Working
Basically I have a landing page that calls ng-repeat and displays a list of data from a json file which populates some dynamic includes. Each list item has a link that all go to t
Solution 1:
Ok I found a solution:
I was trying to do this:
<ng-switch on="'{{post.index}}'">
<ng-switch-when="0" ng-include="'blog/angular/angular_blog' + {{post.index}} + '.html'">
<ng-switch-when="1" ng-include="'blog/angular/angular_blog' + {{post.index}} + '.html'">
</ng-switch>
Changed to this:
<ng-switch on="'{{post.index}}'">
<ng-switch-when="0" ng-include="'blog/angular/angular_blog' + post.index + '.html'">
<ng-switch-when="1" ng-include="'blog/angular/angular_blog' + post.index + '.html'">
</ng-switch>
Works but getting a 404 error: GET http://127.0.0.1:59077/blog/angular/angular_blog.html 404 (Not Found)
Will update the answer once I have figured it out. Thanks
UPDATE: WORKING SOLUTION WITH NO ERRORS
<div ng-if="post.index">
<ng-switch on="post.index">
<ng-switch-when="'0'" ng-include="'blog/angular/angular_blog' + post.index + '.html'">
<ng-switch-when="'1'" ng-include="'blog/angular/angular_blog' + post.index + '.html'">
</ng-switch>
</div>
Post a Comment for "Ng-if, Ng-switch And Dynamic Ng-include Not Working"