The functionality of the State Params is not functioning as expected

Switch to a different page using parameters by

$scope.singlepage = function($url) {
             $url;
             console.log($url);
            $state.go('app.paymentinfo', { "userId": $url});
            }; 

Include state and State param here

angular.module('app.feedback').controller('singleCourseFeedbackCtrl', ['feedbackApiSet','$scope','$state','$stateParams','httpService','fileReader',
    function(feedbackApiSet,$scope, $stateParams, $state,httpService,fileReader){

However, in my code $stateParams and $state got mixed up

When I corrected it like this:

The code is not functioning properly. I get an error in the console saying cannot read property '' of undefined state param

angular.module('app.feedback').controller('singleCourseFeedbackCtrl', ['feedbackApiSet','$scope','$stateParams','$state','httpService','fileReader',
    function(feedbackApiSet,$scope, $stateParams, $state,httpService,fileReader){

How can I retrieve params

$scope.showprofile = $stateParams.params.userId;

My module state looks like this:

.state ('app.singleCourseFeedback', {
                            url : '/singleCourseFeedback/:userId',
            templateUrl : 'modules/feedback/views/singleCourseFeedback.html',
            controller : 'singleCourseFeedbackCtrl'
                        })

Why does everything work when written incorrectly?

Answer №1

Simply utilize the variable $stateParams.userId; without including any parameters.

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

Angular dynamic calculations for min and max values result in an unusual user interface

I am encountering an issue with a datetime-local input field that has max and min attributes. <input type="datetime-local" ng-model="model.date" min="{{min}}" max="{{max}}"> These attributes are dynamically set based on the date from another input ...

What is the best way for Flask to host the React public files?

When working with React, I created a folder called ./public/assets, and placed an image inside it. Running npm start worked perfectly fine for me. However, after running npm run build in React, I ended up with a ./build folder. To solve this issue, I moved ...

What is the best way to transfer my object along with its unique textures from Blender to ThreeJS?

I've been using the STL Loader in three.js to import objects from Blender, but I'm facing an issue where the textures are not appearing. I suspect it has something to do with the MeshBasicMaterial of the object. I attempted to switch it to Phong ...

What steps should I take to transform [“link”, “395868”] into [title: “link”, content: “395868”]?

As a newcomer to javascript, I am finding it challenging to articulate my issue due to lack of adequate vocabulary. My current project involves building a chart with d3 and here is the data I require : data=[ ...

What is the best way to retrieve a style property from a <style> tag using JavaScript?

Is there a way to retrieve CSS properties set in the <style> tag in JavaScript, rather than just those set in the element's style attribute? For example: <style> div{background:red;} </style> How can I access these styles, such ...

Converting a multidimensional array from PHP to JavaScript in Symfony 4

Greetings! I have an array in Symfony within my controller that looks like this: $array = [ "label" => [ "january", "february" ], "data" => [ 0, 1 ] ]; I am loo ...

Having trouble receiving a string response from the responseText

In the process of creating a simple program for updating product prices on a website, I am encountering an issue where the string response is not being returned in my responseText. Here is an outline of the code used across three different files: <scri ...

Retrieve the matrix3d values from the -webkit-transform property

My current endeavor involves rendering 3D shapes using the <canvas> (2d context), requiring manual projective transformations. I am eager to retrieve the 3D transformation matrix values from the CSS, as that would greatly aid my process. Is it poss ...

Extracting the URL of the @font-face declaration in CSS with the use of JavaScript

Currently, my CSS file contains numerous @font-face tags. Each tag specifies a unique font-family and src URL. @font-face{ font-family: Garamond; src: url('ePrintFonts/pcl_91545.ttf'); } @font-face{ font-family: C ...

Using AJAX, retrieve the attribute of a button and assign it to a node

I'm currently facing a dilemma in trying to pass the name of a clicked button to my node server. I have this code snippet in Node.js: app.get('/someUrl', function(req, res) { console.log(req.body.name); }); Meanwhile, my jQuery/ajax ...

Encountering an error message: [$parse:syntax] when trying to implement ng-class

I'm currently working on developing custom form validation, utilizing ng-class to emphasize required fields. Here is the syntax I am using: <div class="form-group" ng-class="{'has-error': dc.{fname}.nedatt({{fname}}.username)}"> ...

What steps are needed to set up my Express server so that it can render all my content, rather than just my HTML file?

I need help setting up a server for my project using Express. Here is the structure of my file directory: root-directory ├── public │ ├── css │ │ └── styles.css │ ├── images │ │ └── img1.png | | └ ...

Tips for utilizing the if statement within ng-repeat in Angular version 1.0.8

My version of angular is 1.0.8-stable My main goal is to arrange data in rows of 3. This is the desired structure for my HTML: <div class="table-row"> <div class="item">item1</div> <div class="item">item2</div> ...

Executing a DELETE request through a hyperlink in a Node.js Express application

I'm working with a route that accepts DELETE requests, and I am aware that in Express you can include <input type="hidden" name="_method" value="delete" /> in a form to send a POST request to the designated URL. But how would you accomplish ...

Position of the item in an array that contains an array with only one item

Currently, I am utilizing the Google Maps API in Angular with TypeScript. My goal is to create a clickable map of countries that changes color when clicked. This task seems simple, but I am encountering a challenge due to the complexity of the ng2-google-m ...

the video feature fails to show any video footage, only displaying a blank white screen

Currently, I am in the process of creating a unique video component using Angular. This component allows me to pass external sources for different videos. Interestingly, when I view the videos without utilizing the component, everything seems to be working ...

Tips on loading a CSV file into memory synchronously prior to processing HTTP requests

Currently, I am in the process of developing a basic express/node.js application that can handle GET requests by utilizing data stored in a CSV file. The main objective is to read this CSV file and then convert its contents into a javascript object, essent ...

"Encountering a problem with Typescript when working with arrays

There are different types that I am working with type Asset = { id: string, name: string, recordedBy: string } type User = { id: string, name: string, dob?: Date } type Device = { id: string, name: string, location: [n ...

Issue with incorrect date being retrieved in MongoDB response from a node server

My date in mongodb is structured as follows: ISODate("2020-08-03T00:00:00.000+05:30"), However, after querying the date, it appears like this: 2020-08-02T18:30:00.000Z I am looking to get the correct date of 2020-08-03. What could I be doing wr ...

Unable to locate the reverse for 'my_views_name' without any arguments in Django. Bridging server-side code with client-side JavaScript using jQuery

How can I create a button to update a URL after fetching data from the database using jQuery AJAX? This is my code in views.py: def list_maingroup(request): lists = MainGroup.objects.all().order_by('-pk') data = [] for i in lists: ...