Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

angularjs can you use a templateurl for a controller?

Posted on 2014-02-18
2
Medium Priority
?
1,802 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 25

Accepted Solution

by:
Kyle Hamilton earned 2000 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses

636 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