[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1905
  • Last Modified:

angularjs can you use a templateurl for a controller?

I am trying to use Angularjs with a current SharePoint site so my architecture might be a little unorthodox.  I want to be able to specify a template url in my controller.  Basically I want to be able to mimic the route functionality of specifying a controller and view without actually using routing.

I can do something like
<div ng-controller="mycontoller">This is my markup {{Name}}</div>

I want the markup to go in another file.

If I was using routing I could do it like below, but without routing:
    $routeProvider
        .when('/mycontoller', {
            templateUrl: '/templatesangular/mycontoller.html',
            controller: 'mycontoller'
        })
0
jackjohnson44
Asked:
jackjohnson44
1 Solution
 
Kyle HamiltonData ScientistCommented:
you could have an include in your view

<div ng-include="template">

and in the controller

$scope.template = "path/to/template.html"

does that make sense?
0
 
jackjohnson44Author Commented:
Thanks!  I had that but apparently my jQuery version was old.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now