Navigating with Angular in SailsJS

Working with sailjs and angular has been causing me some issues. Specifically, when I make a GET request using the URL cate/:id/new, my link ends up looking like

http://localhost:1337/category/5540ba9975492b9155e03836/new

How does angular recognize my ID in this scenario?

I've tried using ngRoute, but when I console.log it, it just returns Object {}

Here's my module.js:

angular.module('DeviceModule', ['toastr', 'ngRoute']);

And here's my controller.js:

angular.module('DeviceModule').controller('DeviceController', ['$scope', '$http', 'toastr', '$routeParams', function($scope, $http, toastr, $routeParams){

$scope.params = $routeParams;
console.log($scope.params);

}])

.config(function($routeProvider, $locationProvider) {
  $routeProvider
   .when('/category/:Id/new', {
   //templateUrl: 'book.html',
   controller: 'DeviceController',
  })
});

Answer №1

Instead of relying solely on extracting information from $location.path(), a more effective approach could be to display it on the page during loading or to keep track of IDs if internal navigation is being utilized within Angular. Based on your current URL, it seems like that may not be the case.

For example, consider using a structure like /items/id123/subitems/id456. Relying heavily on the URL for passing ID information to the application appears to have its complications.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Guide to populating jQuery DataTables with JSON data

I am currently implementing jquery datatable in my application. You can find the plugin link here My goal is to populate the datatable with JSON data, but I have encountered a problem. Here is the code snippet that I am working with: HTML: <table id= ...

Proceed to the following stage by clicking on an element in introJS

I'm currently developing a new application with angularjs and incorporating intro.js for a guided product tour. My goal is to allow the user to click on a specific element, causing intro.js to zoom in on that precise element instead of following the ...

Can someone help me understand this AngularJS code?

Currently, I'm grappling with a form in Angular that's presenting me with an unusual complication. The form resembles a rating system where users are asked to rate 5 questions on a scale of 1-5. Seems simple enough, right? Add up the scores and ...

Changing a list of items with unique identifier keys

I've got add I've got delete now I need to make modifications The add function simply adds to the collection without any organization The delete function is precise, using a key to locate and remove the desired item: addInput = (name) => ...

Displaying images in Angular application from a REST service

Despite conducting extensive research and tests, I am still unable to display an image from a ReST API on my Angular App. The images are available on the ReST web service, and I chose to use a ReST service because authentication is required (I utilize the ...

Attempting to call a Struts 2 action class from AngularJS using an HTTP GET request, however, no response is being received

I have been working on a simple application that involves making a call to Struts 2 through AngularJS. The process includes sending an HTTP GET request from AngularJS to fetch JSON data from the server. On the server side, I have created an action class na ...

What is the best way to navigate to a specific element using jQuery?

I am having an issue with scrolling to a specific div at the top of my page. Even though I have buttons for other sections, when I scroll to the bottom and click on the button, it does not take me to the top of the page as intended. You can view the CodeP ...

What is the best way to retrieve the focused element in a shiny application?

I'm trying to figure out if there's a way to determine in shiny whether the user is focused on a text-field or select field. My website contains various elements such as plots, tables, numerical inputs, and buttons. Currently, I have implemented ...

Activate html5 form validation when clicking on an asp.Net LinkButton using OnClientClick

I am working with a webform application Within the Master Page, I have created a form as follows: <body class="tile-1-bg"> <form id="form1" runat="server"> On my page.aspx file, the form includes the following elements: <div class="contr ...

Not all of the data is being retrieved

A form on the page contains two dropdown lists for selecting blood type and city, along with a button. When the button is clicked, information about donors matching the selected blood type and city will be displayed below the form. The postgres database co ...

translating python's color function to javascript

Can anyone help me convert the Python function below into JavaScript? Thank you! def coloring(a): #takes an integer number, returns rgb color a = a % 255 akM = a // 43 ypD = a % 43 if akM == 0: color = (255, ypD*255/43, 0) elif akM ...

Tips for concealing lengthy text within a select box and automatically wrapping it when displayed as an option

Is there a way to conceal lengthy text within a select box and display it only when the option is selected? I want to hide long text in a select box options, but have some sort of signal to show that more text is available. Is there a javascript solution ...

Error: Unable to access the 'TigerNo' property of an undefined object. Setting tempObj['TigerNo'] to the default TigerNo value from the sports record

I need some help with JavaScript programming. Although I am able to retrieve values in sportsRecord, I am encountering difficulties assigning them to tempObj['TigerNo']. Whenever I try to assign the value, I encounter the following error message ...

Leveraging parent directives in AngularJS to manage actions carried out by child directives

My directive is fairly simple, involving child directives that trigger a function when clicked. <yd-chart-selector> <yd-chart-selector-item button-class="column" on-click="main.drawColumnChart()"></yd-chart-selector-item> <yd- ...

Extract the value of an HTML tag and assign it to a variable

Can someone help me out with this, as I am not very familiar with Smarty: When I use ajax to submit this form: <form accept-charset="UTF-8" method="post" onSubmit="return validate()"> <input type="text" name="code" maxlength="15" class=" ...

Struggling to retrieve information upon form initialization using JavaScript in Yii2

When the salary form loads, I need to retrieve data from the ratechart model and populate certain text fields. In the Ratechart Controller, I have included: public $rateid = '1'; public function actionGetForRatechart($rateid) { $ra ...

Menu options

I am currently working on developing a mouseover navigation website. Initially, my design included main buttons for "Our Team", Locations, and Patient Resources. Here is the basic structure I had before attempting to switch to a mouseover approach... &l ...

"Encountered an error when attempting to load a resource in Node

I'm currently taking a tutorial to learn Node and Angular. Coming from a LAMP stack environment, this new world feels overwhelming and confusing. Although I have installed Angular JS and included it in my HTML file, I keep encountering the following ...

What is the most effective way to loop and render elements within JSX?

Trying to achieve this functionality: import React from 'react'; export default class HelloWorld extends React.Component { public render(): JSX.Element { let elements = {"0": "aaaaa"}; return ( ...

Continuously adjust progress bar data in real time

I am currently working on a task list feature that includes checkboxes similar to the functionality in Trello. The data for this list is being retrieved from a MySQL database. When a user checks a checkbox to mark a task as completed, I use an XMLHttpRequ ...