I've got an ng-include and ng-controller within an ng-repeat, and IE randomly craps itself when it sees the child instance object of the repeat:
inside main.html
<section ng-repeat="panel in sidepanels">
<h2 class="twelve columns">
<span class="twelve">
<i class="icon {{panel.icon}}"></i> <!-- resolves properly -->
{{panel.controller.name}} <!-- empty -->
</span>
</h2>
<div
ng-include src="'views/'+panel.controller.name.toLowerCase()+'.html'"
ng-controller="panel.controller"
></div>
</section>
inside controllers.js
function Main($scope) {
…
$scope.sidepanels = [
{
"controller": Alerts,
"icon": "icon-warning-sign"
}
];
…
}
function Alerts($scope,WebSocket) {
$scope.alerts = [];
WebSocket.on('…', function(data) { … });
WebSocket… //WebSocket is a Service
}
Except instead of throwing an error in console, it just silently ignores the fact that it sometimes can't resolve panel. I only noticed this was the case because I saw a failed GET on views/.html.
I checked MSDN, and supposedly IE supports the name property.
The property name doesn't work very well for functions on IE.
You can use the following snippet to retrieve a function's name (as described here):
func.toString().match(/^function ([^(\s]+)/)[1]
Add a function to your Main controller that creates the template path, like this:
$scope.getTemplatePath= function(controller) {
return 'views/' + angular.lowercase(controller.toString().match(/^function ([^(\s]+)/)[1] + '.html');
};
And on the HTML:
<div ng-include="getTemplatePath(panel.controller)" ng-controller="panel.controller"></div>
jsFiddle: http://jsfiddle.net/bmleite/faGRk/