Angular request - pull dynamic paramater

So essentially this is what I'm trying to do:

Angular Flow within my APP

I'm making a APP that I have to call numerous amounts of dynamically generated JSON urls consistently. The only way I can get that 'JSON/Path' is by adding the url as a parameter within a DOM element. (Legacy system, I know not the most optimal solution here) After I get the request I will be factoring the data back into said div them recompiling the innerHTML.

What I need to know is;

  • After Angular compiles the page and see's ng-controller how can I insert the jsrc (Json Path) into the Get request?
  • Should I do this with a directive? Or can I somehow pick this information up when I go through my controller?

(Fairly new to angular so any help is VERY much appreciated)

Ok, got it for you :

Add an attribute to your div : <div ng-controller="MyCtrl" jsrc="JSON/Path" urlGetter>

directives = angular.module('MyApp', [])

directives.directive ('urlGetter', function() {
    return function(scope, elements, attrs) {
        scope.url = attrs.jsrc;
    }
}

and in your controller :

MyCtrl = function($scope, $http) {
    $http.get($scope.url)...
}

If you want more info about it : http://egghead.io/video/rough-draft-angularjs-useful-behaviors/