0

I have the following URL: http://mysite:9000/#/sso/salesforce/666

I added my route the following way:

$routeProvider
            .when('/sso/salesforce/:companyId', { .... 

I'm trying to resolve the companyId from the URL, in this case 666: http://mysite:9000/#/sso/salesforce/666

I'm injecting $location into a resolve function to resolve the company ID, but I'm not sure how to get it from $location.

$location.search() gives me an object with a property 'companyId: true' I don't need to know that is present, I need to get the actually value 666.

How is this done in angular 1? I'm new to angular, not sure how.

1 Answer 1

1

You can inject and use $routeParams for this as below.

In the config,

$routeProvider.when('/sso/salesforce/:companyId', {
            templateUrl: '/sso/salesforce/' + $routeParams.companyId + '.html'
        });

In the controller,

function RouteController($scope, $routeParams) {
        $scope.templateUrl = '/sso/salesforce/' + $routeParams.companyId + '.html';
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.