如何 link google firebase 到 ionic 的 controller.js 文件?
How to link google firebase to ionic's controller.js file?
我是一名学生,我的团队参加了写作应用程序竞赛。仅凭如此少量的编码知识,我们无法找出以下代码的问题:
angular.module('app.controllers', [])
.controller('studentLoginCtrl', function($scope) {
function login(username,password) {
var ref = new Firebase("https://project-2767910204862952587.firebaseio.com");
ref.authWithPassword({
email : username,
password : password
}, function(error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully with payload:", authData);
window.location = "/SFront";
}
});
}
})
我们已经查阅了相当多的教程和大量的试验和错误。 运行 代码没有显示任何错误,但它什么也没做。
链接到操作的按钮具有以下代码:
<button ng-click="login(username, password)" id="studentLogin-button7" style="font-weight:;" class=" button button-balanced button-block icon-left ion-android-checkmark-circle ">Log in</button>
我已经使用 ng-model 来定向用户名和密码数据。
<ion-list id="studentLogin-list2" class=" ">
<label class="item item-input " id="studentLogin-input4">
<span class="input-label">Username</span>
<input type="email" placeholder="Email" ng-model="username">
</label>
<label class="item item-input " id="studentLogin-input5">
<span class="input-label">Password</span>
<input type="password" placeholder="Password" ng-model="password">
</label>
哪位高手能告诉我们问题的根源在哪里,如何解决?
我没有看到你的路线,也许问题出在这里。您需要 "link" 带有控制器的视图。这是一个例子:
routes.js
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('signup', {
url: "/signup",
templateUrl: "views/signup.html",
controller: "studentLoginCtrl"
})
希望对您有所帮助。
您的按钮的点击事件未绑定到您的函数,您应该在控制器中执行以下操作:
$scope.username = '';
$scope.password = '';
$scope.login = function(username,password) {
//your implemention here
}
$scope
是angular和ionic世界中视图和模型的桥梁。
我是一名学生,我的团队参加了写作应用程序竞赛。仅凭如此少量的编码知识,我们无法找出以下代码的问题:
angular.module('app.controllers', [])
.controller('studentLoginCtrl', function($scope) {
function login(username,password) {
var ref = new Firebase("https://project-2767910204862952587.firebaseio.com");
ref.authWithPassword({
email : username,
password : password
}, function(error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully with payload:", authData);
window.location = "/SFront";
}
});
}
})
我们已经查阅了相当多的教程和大量的试验和错误。 运行 代码没有显示任何错误,但它什么也没做。
链接到操作的按钮具有以下代码:
<button ng-click="login(username, password)" id="studentLogin-button7" style="font-weight:;" class=" button button-balanced button-block icon-left ion-android-checkmark-circle ">Log in</button>
我已经使用 ng-model 来定向用户名和密码数据。
<ion-list id="studentLogin-list2" class=" ">
<label class="item item-input " id="studentLogin-input4">
<span class="input-label">Username</span>
<input type="email" placeholder="Email" ng-model="username">
</label>
<label class="item item-input " id="studentLogin-input5">
<span class="input-label">Password</span>
<input type="password" placeholder="Password" ng-model="password">
</label>
哪位高手能告诉我们问题的根源在哪里,如何解决?
我没有看到你的路线,也许问题出在这里。您需要 "link" 带有控制器的视图。这是一个例子:
routes.js
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('signup', {
url: "/signup",
templateUrl: "views/signup.html",
controller: "studentLoginCtrl"
})
希望对您有所帮助。
您的按钮的点击事件未绑定到您的函数,您应该在控制器中执行以下操作:
$scope.username = '';
$scope.password = '';
$scope.login = function(username,password) {
//your implemention here
}
$scope
是angular和ionic世界中视图和模型的桥梁。