Solved

angularjs can you use a templateurl for a controller?

Posted on 2014-02-18
2
1,612 Views
Last Modified: 2014-02-19
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
Comment
Question by:jackjohnson44
2 Comments
 
LVL 25

Accepted Solution

by:
Kyle Hamilton earned 500 total points
ID: 39869426
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
 

Author Closing Comment

by:jackjohnson44
ID: 39871357
Thanks!  I had that but apparently my jQuery version was old.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now