0
Hi im很新的Angulay js離子開發。即時通訊嘗試基本導航點擊按鈕時。但我得到這個錯誤,當我點擊Firebug控制檯中的按鈕。我想導航到搜索頁面後,點擊它
Error : $state isnot defined
這裏我App.js代碼
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('signin', {
url: "/sign-in",
templateUrl: "templates/sign-in.html",
controller: 'AppCtrl'
})
.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu.html",
controller: 'AppCtrl'
})
.state('app.search', {
url: "/search",
views: {
'menuContent': {
templateUrl: "templates/search.html"
}
}
})
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/sign-in');
});
這裏我控制器
angular.module('starter.controllers', [])
.controller('AppCtrl', function($scope, $ionicPopup, $timeout, $ionicModal) {
$scope.signIn = function(user) {
//console.log('Sign-In', user);
$state.go('app.search');
};
})
我的HTML按鈕
<button class="button button-block button-positive" id="login-btn" ng-click="signIn(user)" type="submit">Log in</button>
你沒有任何名爲'$ state'的東西 – 2015-02-11 20:41:27
注入$狀態到你的控制器中...... – 2015-02-11 20:41:38
噢,非常感謝。 – 2015-02-11 20:45:10