javascript - Angularjs button click with ui router is not working -
hi developing angular js application. using ui-routing technique. facing issues in button click event. below main.js file.
var app = angular.module('roslpapp', ['pascalprecht.translate', 'ui.router']); app.config(function ($stateprovider, $urlrouterprovider, $urlrouterprovider, $translateprovider, $translatepartialloaderprovider) { $stateprovider.state('forgotpassword', { url: '/forgotpassword', templateurl: 'forgotpassword/forgotpassword.html', controller: 'forgotpassword' }); $stateprovider .state('forgotpassword.resetpassword', { url: '/resetpassword', templateurl: 'forgotpassword/resetpassword.html', controller: 'resetpassword' }); }); }); below forgotpassword.html
<div class="container"> <div ui-view></div> </div> here injecting resetpassword.html. below resetpassword.html
<div class="button-container"> <input type="submit" value="submit" id="input-submit" data-ng-click="resetpassword()"> </div> above button not work. resetpasswordcontroller.
(function () { angular.module('roslpapp').controller('resetpassword', ['$rootscope', '$translatepartialloader', '$translate', function ($resetpasswordservice, $scope, $translatepartialloader, $translate) { alert("works"); $scope.resetpassword = function () { var sub = { mobilenumber: $scope.updateid, dob: $scope.updatename }; alert("does not works"); var servcall = resetpasswordservice.resetpassword(sub); servcall.then(function (data) { }, function (data) { alert(json.stringify(data.data)); }); } }]); })(); resetpasswordservice.js
app.service("resetpasswordservice", function ($http, $state) { alert("aaa"); this.resetpassword = function () { var url = '/api/projects/7'; return $http.post(url).then(function (response) { return response.data; }); } });
$scope.resetpassword not working , not getting error also. appreciated. thank you.
your dependency injection order wrong. try one:
(function () { angular.module('roslpapp').controller('resetpassword', ['$scope', '$http', '$translatepartialloader', '$translate', 'resetpasswordservice', function ($scope, $http, $translatepartialloader, $translate, resetpasswordservice) { alert("works"); $scope.resetpassword = function () { var sub = { mobilenumber: $scope.updateid, dob: $scope.updatename }; alert("does not works"); $http.post('/api/projects/7').then(function (response) { alert(json.stringify(response.data)); }, function (error) { console.log(error); }); } }]); })(); resetpasswordservice.js
angular.module('roslpapp').service("resetpasswordservice", function ($http, $state) { alert("aaa"); this.resetpassword = function () { var url = '/api/projects/7'; return $http.post(url).then(function (response) { return response.data; }); } });
Comments
Post a Comment