javascript - ng-click to display user info -
I am very new to JavaScript and Attractors and am trying to do a lot of basic. I want to display information about that specific user on which I click.
I have a list of users I see like this:
& lt; Tr ng-repeat = "users in users" ng-click = "selector ()" & gt; & Lt; Td> {{User.FirstName}} {{user.LastName}} & lt; / Td> & Lt; TD & gt; {{User.Email}} & lt; / TD & gt; & Lt; Td> {{User.RegistrationDate | Date: 'yyyy / MM / dd'}} & lt; / Td> & Lt; / TR & gt; On the click event, there is only one warning that the method in my webapi looks like GetUser (int id) and I have no problem obtaining data.
This looks like my JS controller:
angular.module ('MyApp'). Controller ('userctrl', ['$ scope', '$ http', function ($ radius, $ http) {$ http.get ('/ api / control name'). Civet (function) {$ Scope.users = Data;}) .error (function () {$ scope.error = "data could not be loaded or none.";}) //$scope.selectedUser = function () {// $ Http.get () //} $ scope.selectUser = function () {warning ("some text");}}]);
I do not know how you want to show your data, but when I do this Want to do something about:
& lt; Tr ng-repeat-start = "user in user" ng-click = "user.display =! User.display" & gt; & Lt; Td> {{User.FirstName}} {{user.LastName}} & lt; / Td> & Lt; / TR & gt; & Lt; Tr ng-repeat-end ng-show = 'user.display' & gt; & Lt; TD & gt; & Lt; Div & gt; & Lt; P & gt; {{User.Email}} & lt; / P & gt; & Lt; P & gt; {{User.RegistrationDate | | Date: 'yyyy / MM / dd'}} & lt; / P & gt; & Lt; / Div & gt; & Lt; / TD & gt; & Lt; / TR & gt; and in angular
angular. Module ('myApp'). Controller ('userctrl', ['$ scope', '$ http', function ($ radius, $ http) {$ http.get ('/ api / controllerName'). Then (function (data) {var user = data ; (User in the user) {user [i] .display = false;} $ Scope.users = user;}, function () {$ scope.error = "The data could not be loaded or there was none. ";});}])); angular ng-repeat-start and ng-repeat-end allows you to repeat different tags using the same data Whatever you want, it can be very useful to display the ng-show tag if its ultimate truth is true. Hope it helps.
Comments
Post a Comment