I am new to using angularjs, I started with a blank project and made sure I was able to GET and POST data to mysql db. which I was, I then wanted to use the ionic tabs template for my actual project. how they call the controllers are different then how I did it the first time. I tried debuggin as best I could by placing console.logs to see where it wasnt going and when I click the submit button it goes into the ‘InvoiceCtrl’ but does not seem to be calling the addNewInvoice function in the InvoiceCtrl controller , to post the data. not sure what Im missing here, and I made sure my php file that it is posting to is working correctly.
controller.js
angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope) {})
.controller('AccountCtrl', function($scope) {
$scope.settings = {
enableFriends: true
};
})
.controller('OhsCtrl', function ($scope) {
})
.controller('InvoiceCtrl', function ($scope, $http) {
$scope.addNewInvoice = function (add) {
console.log("in the function");
var data = {
firstname: $scope.newInvoice.firstname,
lastname: $scope.newInvoice.lastname
}
$http.post("http://mrbproduktions.com/app/insert.php", { 'firstname': $scope.newInvoice.firstname, 'lastname': $scope.newInvoice.lastname })
.success(function (data) {
console.log("damn itwork");
});
};
});
app.js
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleLightContent();
}
});
})
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
// setup an abstract state for the tabs directive
.state('tab', {
url: "/tab",
abstract: true,
templateUrl: "templates/tabs.html"
})
// Each tab has its own nav history stack:
.state('tab.dash', {
url: '/dash',
views: {
'tab-dash': {
templateUrl: 'templates/tab-dash.html',
controller: 'DashCtrl'
}
}
})
.state('tab.ohs', {
url: '/ohs',
views: {
'tab-ohs': {
templateUrl: 'templates/tab-ohs.html',
controller: 'OhsCtrl'
}
}
})
.state('tab.invoice', {
url: '/invoice',
views: {
'tab-invoice': {
templateUrl: 'templates/tab-invoice.html',
controller: 'InvoiceCtrl'
}
}
})
.state('tab.account', {
url: '/account',
views: {
'tab-account': {
templateUrl: 'templates/tab-account.html',
controller: 'AccountCtrl'
}
}
});
$urlRouterProvider.otherwise('/tab/dash');
});
and the tabs-invoice.html
<ion-view view-title="Invoice">
<ion-content class="padding">
<div class="list card">
<div class="item item-divider">Customer Information</div>
<div class="item item-body">
<div class="list">
<label class="item item-input item-stacked-label">
<span class="input-label">First Name</span>
<input type="text" ng-model="InvoiceCtrl.firstname" name="firstname" placeholder="John">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Last Name</span>
<input type="text" placeholder="Smith" ng-model="InvoiceCtrl.lastname" name="lastname">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Address</span>
<input type="text" placeholder="123 Main St." ng-model="InvoiceCtrl.address" name="address">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">City</span>
<input type="text" placeholder="City" ng-model="InvoiceCtrl.city" name="city">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Zipcode</span>
<input type="tel" placeholder="Zipcode" ng-model="InvoiceCtrl.zipcode" name="zipcode">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Phone</span>
<input type="tel" placeholder="Phone #" ng-model="InvoiceCtrl.phone" name="phone">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Email</span>
<input type="email" placeholder="johnsmith@gmail.com" ng-model="InvoiceCtrl.email" name="email">
</label>
</div>
</div>
</div>
<div class="button">
<button data-ng-click="addNewInvoice()" name="add">Submit Invoice</button>
</div>
</ion-content>
</ion-view>
any help would be appreciated… LOVING IONIC SO FAR