我有问题。我想调用带参数的函数,并在ng-click
上通过.md-button
获得结果。
在HTML中
<md-button class="md-raised md-primary" ng-click="setreg.register({{reg.email}},{{reg.pass1}},{{reg.pass2}},{{reg.name}});" style="width: 100%">
Kayıt Ol
</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\":\"Şifre doğrulaması yapılamadı\"}]";
} 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;
}]);
有什么问题?我该如何实现它? 最好的问候
答案 0 :(得分:0)
JS
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\":\"Şifre doğrulaması yapılamadı\"}]";
} 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(function (data) { result.SetRegister = data; });
}
};
result.SetRegister = register;
}]);
HTML
<md-button class="md-raised md-primary" ng-click="setreg.SetRegister(reg.email,reg.pass1,reg.pass2,reg.name);" style="width: 100%">
此发送请求问题和响应ok或FAIL eex消息。 service是db。中的数据。