What is $stateProvider in AngularJs?

0 votes
Can someone please provide the syntax and Example of it??
Feb 11 in Angular by kartik
• 10,760 points
565 views

1 answer to this question.

0 votes

Routing is just another way of fixing some content dynamically as part of your application.It is a key part of all websites and web applications in one way or another. 

It plays a central role in static HTML pages as well as in the most complex React web applications. Routing comes into play whenever you want to use a URL in your application.

Angular-UI-Router has stateProvider method which is used to create routes/states in application. State Provider takes state name and state configurations as parameters.

Syntax:

$stateProvider
.state('StateName', {
    url: 'Url pattern for this State',
    template: "Html content",
    controller: "Name of the Controller for this state"
});

Instead of template, templateUrl can be used and given the path of the HTML file to render for the state.
Example:

$stateProvider
.state('Home', {
    url: '/home',
    templateUrl: "home.html",
    controller: "HomeCtrl"
});
    answered Feb 11 by Niroj
    • 21,680 points

    Related Questions In Angular

    0 votes
    1 answer

    What is so different about interpolate in AngularJS?

    hii @kartik, In order to know about what ...READ MORE

    answered Feb 4 in Angular by Niroj
    • 21,680 points
    76 views
    0 votes
    1 answer

    What is Scope Parameter in AngularJS?

    Hey @kartik, Scope Parameter is a collection of ...READ MORE

    answered Feb 5 in Angular by Niroj
    • 21,680 points
    50 views
    0 votes
    1 answer

    What is isolated Scope in AngularJs?

    Hello kartik, As we know Scope is a ...READ MORE

    answered Feb 5 in Angular by Niroj
    • 21,680 points
    30 views
    0 votes
    1 answer

    What is transclusion in AngularJS?

    Hey, Let me explain you about transclusion from ...READ MORE

    answered Feb 5 in Angular by Niroj
    • 21,680 points

    edited Feb 5 by Niroj 36 views
    0 votes
    1 answer

    What are the $route service Events provide in AngularJs?

    hey, $route is used for deep-linking URLs to controllers ...READ MORE

    answered Feb 10 in Angular by Niroj
    • 21,680 points
    35 views
    +10 votes
    12 answers

    Default parameters of XMS and XMX in JVM

    You use these Java command-line parameters to ...READ MORE

    answered Nov 13, 2018 in Java by Murali
    213,661 views
    0 votes
    1 answer

    how to compare two words in java?

    hey,  I think in your code the function ...READ MORE

    answered Aug 7, 2019 in Java by sampriti
    • 1,100 points

    edited Aug 8, 2019 by Kalgi 1,425 views
    0 votes
    1 answer

    How to add items in list at a time?

    Hi Priyanka , I think this code snippet ...READ MORE

    answered Aug 9, 2019 in Java by sampriti
    • 1,100 points
    1,594 views
    0 votes
    1 answer

    What is $watch() and it's use in AngularJS?

    $watch() function is used to watch the ...READ MORE

    answered Feb 3 in Angular by anonymous
    • 21,680 points
    74 views
    0 votes
    1 answer

    What is $parse in Angularjs

    Before we jump into the topic you ...READ MORE

    answered Feb 4 in Angular by Niroj
    • 21,680 points
    130 views