-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmeteor-ionic-starter.js
86 lines (72 loc) · 2.03 KB
/
meteor-ionic-starter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
if (Meteor.isClient) {
var app = angular.module('starter', [
'angular-meteor',
'ui.router',
'ionic'
]
);
function onReady() {
angular.bootstrap(document, ['starter']);
}
// the web and cordova fire different events for readiness
if (Meteor.isCordova) {
angular.element(document).on('deviceready', onReady);
} else {
angular.element(document).ready(onReady);
}
// route config
app.config(function($urlRouterProvider, $stateProvider, $locationProvider){
// avoid page refreshes on navigation
$locationProvider.html5Mode(true);
// map the urls to templates to load
$stateProvider
.state('index', {
url: '/',
templateUrl: 'index.ng.html'
})
.state('second', {
url: '/second',
templateUrl: 'second.ng.html'
})
// if nothing matches, back to home
$urlRouterProvider.otherwise("/");
});
// controller config
app.controller('TestController', function($scope, $meteor, $http) {
$scope.message = 'Hello from the Angular Controller';
$scope.changeAngularText = function() {
this.message = 'New Message from the Angular Controller';
};
$scope.changeMeteorText = function() {
var self = this;
$meteor.call('changeText').then(
function (data) {
self.message = data;
},
function (err) {
console.log('error', err);
}
);
};
$scope.callRemote = function() {
var self = this;
self.message = 'hi';//response;
$http.get('/remote/1')
.success(function(response){
self.message = response;
});
};
});
}
if (Meteor.isServer) {
Meteor.methods({
changeText: function () {
return 'New Message from the Meteor Controller';
}
});
Picker.route( '/remote/:_id', function( params, request, response, next ) {
response.setHeader( 'Content-Type', 'text/plain' );
response.statusCode = 200;
response.end('Remote with ' + params._id);
});
}