A
A
Abc Edc2015-02-18 08:45:53
Angular
Abc Edc, 2015-02-18 08:45:53

How to make :id in angular?

Well, that is, like viewing profiles in VK, for example, I click on an item, the item ID is displayed in the URL, and in the meantime, data on the item with the given ID comes from the server.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Konovalov, 2015-02-18
@gleber1

To do this, you need another backend to take data from the database.
the meaning is something like this:
- you make a route (for example, using the UI Router) in an angular type:

$stateProvider
    .state('profileView', {
      url: "/profile/:id",
      controller: 'ProfileController'
    })
});

- in the ProfileController you will have a thread of a service that returns profile data (ProfileService.getProfile(id);)
- inside the service there will be something like:
getProfile: function(id) {
     return $http.get('api/profile/' + id);
}

-then on the backend, at the address 'api/profile/' + id spit out the profile data
on suitable links, I can advise https://scotch.io/tutorials/creating-a-single-page...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question