Solved

angularjs can you use a templateurl for a controller?

Posted on 2014-02-18
2
1,598 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
Comment Utility
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
Comment Utility
Thanks!  I had that but apparently my jQuery version was old.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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)

743 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

8 Experts available now in Live!

Get 1:1 Help Now