Search Posts

Author: user1261710

AngularJS – how to write a unit test containing the momentjs library?

I am writing an app with AngularJS 1.5.3. I want to test one of my services and I want to use momentjs in the tests. test example: it(‘should have the correct number of weeks in the calendar month for Feb’, function () { var dateString = ‘2018-02-01’; Calendar.data.currentCalendarMonth = moment(dateString).startOf(‘month’); Calendar.buildMonth(); var start = moment(dateString).startOf(‘month’).isoWeek(); var end = moment(dateString).endOf(‘month’).isoWeek(); expect(end – start + 1).toBe(Object.keys(Calendar.data.weeks).length); }); When I run the tests I get this error: TypeError: […]

Ionic and AngularJS – on hold event callback firing multiple times in parent component

I am writing an app with AngularJS 1.5.3 and Ionic 1.3.5. I want to implement the on hold feature so when the user presses and holds on an entry I can show a popup box. The problem I am having in my code is that the parent component callback gets called 3 times but the child one is just once. Here is my fiddle: https://jsfiddle.net/aubz88/72hz0ard/ Sorry, in my fiddle I could not get the on-hold […]

AngularJS – child component not updating parent component data

I’m writing an app with AngularJS 1.5.3 I have a parent component with some data in it that needs to be updated in the child component. Right now the data is not updating in the parent component even though the input boxes on the child look like they are updating. Here is my fiddle: https://jsfiddle.net/aubz88/ab85L19c/ Here is some sample code: var grandChildComponent = { bindings: { min: ‘<‘, max: ‘<‘ }, template: ` <div> Grand […]

How to use iBeacon in an Ionic1 app?

I am writing an app that will detect the beacons around it when bluetooth is on. It’s with Ionic v 1.3.5, cordova cli v 8 and AngularJS 1.5.3. I have been trying to use this plugin: http://ngcordova.com/docs/plugins/beacon/ I also tried to follow this tutorial: https://www.thepolyglotdeveloper.com/2015/09/support-ibeacons-in-your-ionic-framework-mobile-app/ I got the plugin running but it does not detect any iBeacons even when they are sitting on my desk! I tried this Android app ibeacon detector and it found […]

AngularJS – max validation not working on time input

I am writing an app with AngularJS 1.5.3. I have an input form with a time input box. I need to have validation on the box such that the user cannot pick a time in the future. Here is a snippet: <div ng-controller=”myController as accvm”> <form name=”accvm.addForm” novalidate> <div class=”item item-input” ng-class=”{ ‘has-error’ : accvm.addForm.time.$invalid }”> <span class=”input-label”>’Time'</span> <input name=”time” type=”time” id=”timeInput” max=”{{ accvm.data.maxTime | date:’HH:mm’ }}” ng-model=”accvm.data.time” ng-change=”accvm.timeChange()” style=”text-align: right” required /> </div> </form> […]

Cordova – how do I know if my app is using the HTML5 Geolocation API or the cordova geolocation plugin?

I am developing an Angular 1.5.3/Cordova 6.5/Ionic 1.3.3 App. In my app I intend to use the cordova geo-location plugin. The app will run in WebView (usually Chrome Stable on Android). Here is my package.json file: { “name”: “myApp”, “description”: “yadda”, “version”: “4.2.0”, “private”: true, “dependencies”: { “angular”: “1.5.3” }, “devDependencies”: { }, “cordovaPlugins”: [ “[email protected]”, “[email protected]” ] } I notice that there is an HTML5 API to detect geolocation: https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition I also notice a […]

Why does Ionic Deploy add ionicCacheBuster to all of my files and calls?

I have an Ionic v1 app with ionic deploy. When my app starts up in the angular.run() block I have some code checking for a snapshot. $ionicDeploy.check().then(function (snapshotAvailable) { if (snapshotAvailable) { $ionicDeploy.download().then(function () { return $ionicDeploy.extract().then(function() { $ionicPopup.show({ title: ‘Update Available’, subTitle: ‘An update was just downloaded. Would you like to restart your app to use the latest features?’, buttons: [ { text: ‘Cancel’ }, { text: ‘Restart’, onTap: function(e) { $ionicDeploy.load(); //no code […]