AngularUI loading modal template from direct path in ASP.NET.MVC

From here you can see that you can load html fragments from ASP.NET.MVC controller, which returns a view:

Angular ng-include cshtml page

<div ng-include="'Home/Template/login'"></div>

I tried doing the same with AngularUI modal window :

var modalInstance = $modal.open({
        templateUrl: "'Home/Template/Modal'"
    });

Getting error :

GET http://localhost:3289/'Home/Template/Modal' 404 (Not Found) 

So it is including the quotes in the path, any suggestions how to load HTML fragments from MVC View folder?

Answers


The templateUrl property of the $modal service doesn't behave the same as ng-include (not sure why you've assumed this) in the sense that it is not AngularJS expression but rather a simple JavaScript expression. As such it doesn't need double-quoting to refer to a fixed JavaScript string.

Just write:

var modalInstance = $modal.open({
    templateUrl: 'Home/Template/Modal'
});

Need Your Help

OpenAL playback captured audio data c++

c++ audio capture playback openal

I am trying to create a voice chat program using OpenAL. The networking side of things seems to be ok but I'll take advice on that =]

2d Platformer physics

physics tile-engine

It was a long holiday weekend, so I got the coding bug again and started playing around: