Calling Routes from a js angular 1.5.8 file

Fedeco

I've my backend developed in Silex with various routes that I can fully access using localhost:8080/project/api/index.php/user (example of a route).

if i'm coding an http get(I use only one controller called mainController ) in a js file using angular 1.5.8, how can I make that when I enter angularsite/user

(user is the route, "/user"), it returns me the data and then show it on my index.html ?

Nitheesh

You need to set your app routes to your mainController controller.

angular.module('YourProject', [
    'YourModule',
    'ngRoute'
])

.config(['$routeProvider', function ($routeProvider) {

        $routeProvider.when('/user', {
            templateUrl: 'view.html',
            controllerAs: 'mainCtrl',
            controller: 'mainController '
        });

        $routeProvider.otherwise({
            redirectTo: '/user'
        });
}])

Now when the page loads the RouteProvider will finds the default path to user (default route) route and that will load your view and controller. The templateUrl contains the route to the template.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Calling a method in an angular Component from an external JS file

From Dev

send varible to js file from routes nodejs

From Dev

Angular 5 set routes from API with Angular Universal

From Dev

Angular 5: calling method from html

From Dev

(Angular 5+) Getting data from child routes

From Dev

Angular 5 Build routes from API data at startup

From Dev

Vue - calling REST API from js file

From Dev

Calling .js file from HTML using AJAX

From Dev

Calling npx from a node.js file

From Dev

Calling method from compiled js file

From Dev

Calling a function from a JS file not working

From Dev

Rails routes for js file

From Dev

Angular 7 - 8 dynamic routes

From Dev

Angular tab is not working in template calling through routes

From Dev

Calling a PHP (Fat Free Framework) file from a bash script in Linux is giving me "No Routes Specified" error

From Dev

HttpErrorResponse when calling .net core method from Angular 8

From Dev

I get undefined from calling a service in a component Angular 8

From Dev

Calling a Javascript function from an external js file in the html file

From Dev

Vue.js calling an async function from external js file

From Dev

Calling Function from another JS file(not a game state) Phaser js

From Dev

Calling a JS function from a JS-File in PHP

From Dev

External .js file in an Angular 8 project

From Dev

creating routes using Angular JS

From Dev

Dynamically Creating Routes in Angular JS

From Dev

Adding an external JS file to Angular 5 CLI

From Dev

Angular 5: adding types to external JS file

From Dev

Express Routes in a Single .js File

From Dev

Angular + firebase: .then() not working when calling function from a service file

From Dev

calling variables from typescript file in html template [angular]

Related Related

  1. 1

    Calling a method in an angular Component from an external JS file

  2. 2

    send varible to js file from routes nodejs

  3. 3

    Angular 5 set routes from API with Angular Universal

  4. 4

    Angular 5: calling method from html

  5. 5

    (Angular 5+) Getting data from child routes

  6. 6

    Angular 5 Build routes from API data at startup

  7. 7

    Vue - calling REST API from js file

  8. 8

    Calling .js file from HTML using AJAX

  9. 9

    Calling npx from a node.js file

  10. 10

    Calling method from compiled js file

  11. 11

    Calling a function from a JS file not working

  12. 12

    Rails routes for js file

  13. 13

    Angular 7 - 8 dynamic routes

  14. 14

    Angular tab is not working in template calling through routes

  15. 15

    Calling a PHP (Fat Free Framework) file from a bash script in Linux is giving me "No Routes Specified" error

  16. 16

    HttpErrorResponse when calling .net core method from Angular 8

  17. 17

    I get undefined from calling a service in a component Angular 8

  18. 18

    Calling a Javascript function from an external js file in the html file

  19. 19

    Vue.js calling an async function from external js file

  20. 20

    Calling Function from another JS file(not a game state) Phaser js

  21. 21

    Calling a JS function from a JS-File in PHP

  22. 22

    External .js file in an Angular 8 project

  23. 23

    creating routes using Angular JS

  24. 24

    Dynamically Creating Routes in Angular JS

  25. 25

    Adding an external JS file to Angular 5 CLI

  26. 26

    Angular 5: adding types to external JS file

  27. 27

    Express Routes in a Single .js File

  28. 28

    Angular + firebase: .then() not working when calling function from a service file

  29. 29

    calling variables from typescript file in html template [angular]

HotTag

Archive