The submit post button is not working, neither is the name of the user and logout button. Perhaps someone can help me with this?
F12 and jsintrc doesnt show anything meaningful.
This is the html for the create new post button which is supposed to lead to a newpost.html page.
<ion-nav-bar></ion-nav-bar>
<ion-nav-view>
<ion-nav-bar></ion-nav-bar>
<ion-view ng-controller="NavCtrl">
<ion-nav-buttons side="left" type="bar-light" ng-submit="submitPost()">
<button class="button button-icon ion-compose" href='/tab/newpost'></button>
<button class="button-clear" href='/tab/posts'><b>MyApp</b></button>
</ion-nav-buttons>
<ion-nav-buttons side="right">
<button class="button-clear" href="#/users/{{ currentUser.username }}">
<img ng-src="http://www.gravatar.com/avatar/{{ currentUser.md5_hash }}"
class="nav-pic"/>{{ currentUser.username }}
</button>
<button class="button-clear" href="#/auth/login" ng-click="logout()">Logout</button>
</ion-nav-buttons>
This is the controller
app.controller('NavCtrl', function ($scope, $location, Post, Auth) {
$scope.post = {url: 'http://', title: ''};
$scope.submitPost = function () {
Post.create($scope.post).then(function (postId) {
$scope.post = {url: 'http://', title: ''};
$location.path('/posts/' + postId);
});
};
$scope.logout = function () {
Auth.logout();
};
});
And the app.js file
app.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('tab.newpost', {
url: '/newpost',
views: {
'tab-newpost':{
templateUrl: 'templates/tab-newpost.html',
controller: 'NavCtrl'
}
}
})
ng-submit
directive is meant to be used with form.
<form
ng-submit="">
...
</form>
use ng-click
instead. But I don't know using ng-click
is a good idea in ion-nav-buttons
. Try using it on buttons or divs instead.
Good luck!