Ideally, when I click on the button (which is located on the Ionic navigation bar at the top), it should bring me to another page. However its not working. After clicking the navigation bar button, everything disappears.
When I used dummy codes, it works; a warning appears. But when I change it to the actual code, it does not work.
I have a feeling what is wrong with the controller codes and how the URL or view is referenced. But testing with href and ui-sref also gives nothing. Google Devt Tools (JS console) and Batarang also show nothing.
Can someone show me please?
dummy html code
<button class="button button-icon ion-compose" ng-click="create()"></button>
dummy controller code in js file
$scope.create = function() { alert("working"); };
actual html code (I tried all 4 versions)
<button class="button button-icon ion-compose" ng-click="create('tab.newpost')"></button> <button class="button button-icon ion-compose" ui-sref="tab.newpost"></button> <button class="button button-icon ion-compose" href="/tab/newpost"></button> <button class="button button-icon ion-compose" ng-click="location.path('/tab/newpost')"></button>
Controller file (Post and Auth dependencies work fine). When I try to put the URL in the .go () and function () functions, the application does not work.
app.controller('NavCtrl', function ($scope, $location, $state, Post, Auth) { $scope.post = {url: 'http://', title: ''}; $scope.create = function() { $state.go("/tab/newpost"); }; });
Extract js state file
.state('tab.newpost', { url: '/newpost', views: { 'tab-newpost':{ templateUrl: 'templates/tab-newpost.html', controller: 'NewCtrl' } } }); $urlRouterProvider.otherwise('/auth/login');
javascript html angularjs ionic-framework
Thinkerer Aug 23 '14 at 17:01 2014-08-23 17:01
source share