I'm encountering an issue. I need to trigger a function with arguments and receive results upon clicking on a .md-button
with ng-click
.
Here's the HTML:
<md-button class="md-raised md-primary" ng-click="setreg.register({{reg.email}},{{reg.pass1}},{{reg.pass2}},{{reg.name}});" style="width: 100%">
Register
</md-button>
<div>
<label>Result :</label>{{setreg.SetRegister}}
</div>
JS
var app = angular.module("demoApp", ["ngMaterial", "ngMessages"]);
app.controller("SetRegister", ["$http", function ($http) {
var result = this;
var dbName = "0";
var dbUserName = "0";
var dbPassword = "0";
var dbUrl = "0";
var register = function (email, pass1, pass2, name) {
if (pass1 !== pass2) {
result.SetRegister = "[{\"result\":\"Password verification failed\"}]";
} else {
var query = "INSERT INTO users (FullName,email,Pass) VALUES ('" + name + "','" + email + "','" + pass1 + "')";
var url = "http://37.247.113.31:20083/Services/SetData.aspx?dbUrl=" + dbUrl + "&dbUName=" + dbUserName + "&dbPass=" + dbPassword + "&dbDbName=" + dbName + "&query=" + query;
$http.get(url).success(function (data) { result.SetRegister = data; });
$http.get(url).error(alert("ERROR"));
}
};
result.SetRegister = register;
}]);
Can you spot any issues with this code? How would you go about fixing it? Sincerely