$routeProvider without templateUrl

1,329 views
Skip to first unread message

donnan...@gmail.com

unread,
Jul 3, 2012, 9:51:32 AM7/3/12
to ang...@googlegroups.com
Greetings
First off all, I'm new to AngularJS, so please be patient with me

I'm trying to use $routeProvider without the "templateUrl", but the controller doesn't seem to load.
Here's my code:

app = angular.module('doc', []).config(
    ['$routeProvider', function($routeProvider) {
        $routeProvider.when('/inbox', {
            controller: InboxCntl,
        }).
        otherwise({redirectTo: '/inbox'})
    }]
)

function MainCntl($scope, $http, $location) {
    $http({method: 'GET', url: '/api/tags/get'}).
            success(function(data, status, header, config) {
                $scope.tags = data
                $scope.nTags = data.length
                
            })
            
    $scope.toggle = function(event) {
        ele = angular.element(event.target)
        if((ele.next().css('display')) != 'none')
            return
        angular.element('.collapse-body').hide(200)
        ele.next().toggle(200)
    }
}


function InboxCntl($scope, $http, $routeParams, $route) {
    $http({method: 'GET', url: '/api/feeds/get'}).
        success(function(data){
            $scope.feeds = data
        })
}


Is this posible?? if it is, what i'm i doing wrong
Thanks!!!

Pawel Kozlowski

unread,
Jul 4, 2012, 11:54:34 AM7/4/12
to ang...@googlegroups.com
hi!

On Tue, Jul 3, 2012 at 3:51 PM, <donnan...@gmail.com> wrote:

> I'm trying to use $routeProvider without the "templateUrl", but the
> controller doesn't seem to load.

Just out of curiosity: why would you like to have a new route without
specifying a template? The purpose of a routes is to change view /
controller in response to URL changes after all...

Could you elaborate a bit more on your use case? Maybe you are just
trying to use a wrong tool for the job at hand?

Cheers,
Pawel

donnan...@gmail.com

unread,
Jul 4, 2012, 12:01:55 PM7/4/12
to ang...@googlegroups.com
I want to change de view, but with json, not with html. I'm doing this because the "app" I'm doing will have later on an android, iOS, etc. version, so if i can bring things with json, i don't have to redo all the work for every app (webApp, androidApp, iOSApp)
The changes in the view are going to be created with js (   $('<div>', {'ng-repeat' = 'thing in things'})     ,etc. which i don't know if it's possible)

If i'm doing things wrong please tell, I'm really knew with Angular

Thank for the reply

Zosia Sobocińska

unread,
Dec 30, 2012, 8:10:50 PM12/30/12
to ang...@googlegroups.com, donnan...@gmail.com
Hi.
This issue also concerns me. I would love to know some way to set controller and use $routeParams without injecting any HTML. My problem is that I'm writing BlackBerry app with filesystem access, but using filesystem api combined with outher HTML injection raises Security Error. I hoped to create separate angular app (filesystem.html) sharing controllers with base app (index.html) and to access $routeParams in those controllers. Is it possible somehow?

If it's not possible, I'll do my best with local storage, but that's not most angular way I guess... :)

Thanks in advance :)
Zosia

ravi tej

unread,
Feb 24, 2013, 5:09:58 AM2/24/13
to ang...@googlegroups.com, donnan...@gmail.com
Hah.I've the same problem dude.I have a Main html page which loads the view for reports.Then I do Ajax calls to get the json based on the request and change the view in the same page,instead of an html template.Still I am not able to find a solution for adding Ajax History for my app.Did anybody solve this problem.Any workarounds ??
Reply all
Reply to author
Forward
0 new messages