Situation
I am trying to enable partial with ng-include without the need for any routing. I just want to include a specific partial of many dynamically. It more or less looks like this:
<div ng-controller="SomeController"> //This controller defines a $scope.getPartial(id) <ng-include src="getPartial(something.id)"></ng-include> </div>
It works, part is on. But, looking at the console, I see that the controller is called several times, and on the first call I get 404
GET path / to / partials / undefined.html [HTTP / 1.1 404 not found 162ms]
it seems that something.id is not defined when the inclusion is done for the first time.
Questions
- How can I just enable partial without creating a new area?
- If this is not possible, how can I make sure the controller is called only once?
- and how can i avoid 404?
I am new to AngularJS and therefore may be mistaken in assumptions about things or miss obvious things, please enlighten me.
markus
source share