IBM MobileFirst Platform and Mobile Angular UI - angularjs

I have created an MFP project with the MFP CLI
After creating the project, I ran "yo mobileangularui" in the project root to install Mobile Angular UI
This scaffolds out a Mobile Angular UI project with AngularJS and Gulp
I am minifying all the js and css files, including the MFP javascript files and putting them in the MFP common folder with gulp
Everything loads fine when I view it in the MFP console, but not on localhost.
My problem is that the sidebars do not work when I click on them. I am not getting any errors. I log a message console.log when I click the menu button and it comes through fine, but it doesn't open the side bar.
If I build this project with out MFP everything works fine.
Not sure whats going on as everything with MFP seems to load fine in the console.
Some images:
https://drive.google.com/file/d/0B48-zmJJTxrYamgtcEtiNi1OMmc/view?usp=sharing
https://drive.google.com/file/d/0B48-zmJJTxrYeG1NUHNpbHA0ZUE/view?usp=sharing

I have never used AngularJS Mobile UI tooling, but the WL is undefined error (that is discussed in the comments) is occurring because of the way you are injecting source to the index.html.
This is how the resulting (part of the) HTML should look:
...
...
<script src="worklight/cordova.js"></script>
<script src="worklight/wljq.js"></script>
<script src="worklight/worklight.js"></script>
<script src="worklight/checksum.js"></script>
<script>window.$ = window.jQuery = WLJQ;</script>
<script src="js/app.min.js"></script>
But this is how it's actually looking:
...
...
<script src="worklight/cordova.js"></script>
<script src="worklight/wljq.js"></script>
<script src="worklight/worklight.js"></script>
<script src="worklight/checksum.js"></script>
<script src="cordova.js"></script>
<script>window.$ = window.jQuery = WLJQ;</script>
<script src="js/app.min.js"></script>
As you can see there are two Cordova references, one correct (worklight/cordova.js) and one incorrect (cordova.js)
The extra cordova.js is apparently coming from gulpfile.js at line #148 where it inject.push (path-to-cordova.js). This injection should be removed or handled differently because MFP already uses Cordova and injects it. Use MFP's.
You can also fix the header. It seems to happen because of the following in app.min.css:
.app-body, .app-content {
height: 100%;
overflow: hidden;
display: block;
padding: 0;
}
Change padding: 0 to padding-top: 25px;. But that may be iOS-specific... meaning you will not see it when previewing the app in the MFP console, because there is no status bar there unlike in the iOS Simulator/device.

The problem with angular mobile ui was my manual bootstraping of angular for MFP
i was using
angular.element(document).ready(function(){
angular.bootstrap(document, ['yoMAUI']);
location.hash = '/';
});
When I need to bind to that body and not the document like so
var body = document.getElementsByClassName("body") ;
angular.element(document).ready(function(){
angular.bootstrap(body, ['yoMAUI']);
location.hash = '/';
});
Is this going to mess with MFP at all, it all? seems to be running fine in the console

Related

Expose Loader does not export module globally

We have reactjs components using some external(coffee script widgets) exported globally using expose-loader. It works fine on chrome, but facing issue on IE11 Globally exposed modules are not accessible. Gives below error SCRIPT5009: 'dashboard' is undefined.
exposed module as below
require("expose-loader?widgets!../widgets");
When we try to access window.widgets or widgets it gives undefined on IE11, but works fine on Chrome
Double-check how your script files are being inserted. I was running into a similar issue with jQuery on a webpack-powered legacy Wordpress site. I just discovered that adding type="module" into my script tags was breaking the expose-loader on IE11. As soon as I removed that attribute from my script tags, everything started firing fine again in IE11.
For example, this will break IE11:
<script defer src="myModule.js" type="module" crossorigin>
While this won't:
<script defer src="myModule.js" crossorigin>

Angular js is undefined in IE8 When view page

i am using angularJS 1.6.4 but when we view the page in IE8 we are getting the below errors
Message: 'angular' is undefined
As others mentioned, IE8 is not supported by AngularJS, but there is a npm package called angularjs-ie8-build which can be used, however they also not guarantee that everything will work.
In order to use this package, you need :
es5-shim
jQuery 1.*
AngularJS 1.4.* build from this repo (some poly-fills are baked in and minor fixes to enable IE8 support)
You need to add this in your head tag before loading angular :
<!--[if IE 8]>
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/4.0.5/es5-shim.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<style>
.ng-hide {
display: none !important;
}
</style>
<![endif]-->
For more information read the package description :
https://www.npmjs.com/package/angularjs-ie8-build

Display issue in an Ionic / Angular app running in IBM mobilefirst

It's my first time to start working on mobile apps using angular and ionic so forgive me if this is just a simple problem. I tried googling about this issue but to no avail. Here's the problem, I tried recreating the sample app created using Ionic in the link below.
link here
I used the IBM MobileFirst environment to run my application. The issue is, if I didn't add a lot of < br > tags before the closing tag of the body, the display would look like the one on the right (see attached image).
Anyone can tell me why this is happening?
Code snippet from image on the left:
....
....
<script src="ionic/js/ionic.bundle.js"></script>
<!-- New lines to load our modules -->
<script src="app/app-main.js"></script>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br>
</body>
</html>
Code snippet for the one on the right
....
....
<script src="ionic/js/ionic.bundle.js"></script>
<!-- New lines to load our modules -->
<script src="app/app-main.js"></script>
</body>
</html>
So basically, it only gets fixed if I add lots of < br > tags before the body's closing tag. Isn't Ionic suppose to adjust to the full height? or the natural height of its contents?
Note: let me know if you cant see the image
There is pre-existing CSS in Worklight that may cause this. You can attempt at fixing it by adding:
html, body {
height: 100%;
}
It is suggested that instead of using Hybrid apps, you'll use Cordova apps in MobileFirst 7.1. Integration with Ionic is then much simpler. Read more here: https://www.raymondcamden.com/2015/03/23/working-with-ibm-mobilefirst-and-the-ionic-framework/

windows phone 8 doesnt support angularjs routing

I have created an app using phonegap for iphone, android and windows.
iphone and android works fine but in windows phone I am able to see only home page there is something issue with angularjs routing when I touch on any link it display page not found. Or ng-href is not redirecting to respective page.
Please help its the crical and wierd issue for me.
Thanks,
Vijay
You will need to provide more details and some code snippet of your app, otherwise it'll be difficult to answer your question.
I encountered similar issue before, and these are the things that I did to solve it:
Specify namespace in your html and put the ng-app in the html tag
<html xmlns:ng="http://angularjs.org" ng-app="app" id="ng-app">
Manually run your angular on device ready event
document.addEventListener('deviceready', function() {
angular.bootstrap(document, ['app']);
}, false);
Make sure you have included ngRoute, in your index.html
<script src="lib/angular-route.js"></script>
and in your angular
var app = angular.module('app', ['ngRoute']);
Watch out for jQuery if you are using any, sometimes it is the jQuery that is causing the problem/ incompatible.
There is also XHR problem: https://github.com/angular/angular.js/issues/4288#issuecomment-26429558, so just make sure you are using the latest Phonegap.
Just some of the general answer that I could give, hope it solve your issue.

Can not open datepicker in angularjs using bootstrap UI

Hello I am using UI Bootstrap for displaying datepicker in my app.
this is my reference order:
<!--ANGULAR CORE-->
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular-route.min.js"></script>
<!--APPLICATION INIT-->
<script src="app/js/app.js"></script>
<!--JQUERY-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<!--BOOTSRAP UI-->
<script src="app/js/libs/ui-bootstrap-tpls-0.11.0.min.js"></script>
I use the tpls version because it supposes to include the templates.
I inject the dependency like that:
angular.module('globapp', ['ngRoute', 'ui.bootstrap'])
when I try to popup the datepicker it doesn't show. In the chrome developer I can see that the code searches for template folder, and I recieve 404 error (datepicker.html, popup.html).
I searched about that in the internet, and everyone tells the same thing: if I use the tpls version, it should provide me the default templates.
thanks
Your app.js has your app init -so that's where your creating your angular module and are hoping to inject bootstrap-ui as a dependency but that script hasn't been loaded yet as it's last in the list.
This would be the first thing to check. Load your scripts in order of least dependent first so jquery first then your core angular, then your plugin libraries and then your app scripts.

Resources