Reputation: 67
So I'm creating an ionic app with my Uni group and i need to create a tab that will show information from a json file. So once I have the page created I can click a link to check it with the dev view as I progress but I need a way to access the page. I want this div in this snippet of code to on open this tab/page I will create in the future, currently it should just open a prompt but it doesn't do anything.
</ion-header-bar>
<ion-content>
<ion-list class="eventList">
<div on-tap="noise()">
<ion-item>
<a class="item item-thumbnail-left" href="#">
<img src="img/ionic.png" class="eImage"/>
<h2 class="eTitle">CLICK ME!</h2>
<p class="eDateTime">23/07/17, 12:30pm</p>
<p class="eDesc">Here there will be a brief description of the event.</p>
</a>
</ion-item>
</div>
If we have a look in the app.js file we can see I have linked the controller
.state('tab.home', {
url: '/home',
controller: "AppCtrl",
views: {
'tab-home': {
templateUrl: 'templates/tab-home.html'
}
}
})
if we look in the index.html file we can see I've linked the location of the script
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
and if we have a look in the Controller.js we can see the prompt code
var App = angular.module("App", ["ionic"]);
App.controller("AppCtrl", ["$scope", "$log", AppCtrl]);
function AppCtrl($scope, $log) {
$scope.noise = function() {
alert("Button pressed");
}
};
I'm very new to ionic applications and I already feel beyond stupid for asking this question but how can I achieve this? My google fu is clearly lacking but one needs to know the correct search terms to find the terms they are in fact searching for.
Upvotes: 2
Views: 71
Reputation: 136134
Having controller: "AppCtrl",
on state level option wouldn't get under consideration(meaning controller
& templateUrl
would get ignored if you have views
option mentioned on state), as you are specifically going to mention controller
& templateUrl
's from views
section of state.
Code
views: {
'tab-home': {
templateUrl: 'templates/tab-home.html',
controller: "AppCtrl" //shifted controller to here
}
}
Upvotes: 1