Integration of "angular-cron-jobs" with the latest Angular 2 Applications - angularjs

Anytime I import this module "Angular-cron-jobs" in the Ionic 2 / Angular 2 using the ngModule decorator, I get the
"angular is not a function".
Is there a way around this or is there an angular2 version of this module?
"angular-cron-jobs" is a cron job UI directive from https://github.com/angular-cron-jobs but I noticed it's written in angular 1.*
How can I get it to work or is there a similar module doing the same thing? Thanks in advance.

Related

Is there any alternative to UpgradeAdapter.registerForNg1Tests?

I have an Angular hybrid app which use UpgradeModule. The AngularJS components depend on Angular services downgraded by downgradeInjectable. When I unit test the components, I saw this error.
Error: Error while instantiating injectable 'MyService': Not a valid '#angular/upgrade' application.
Did you forget to downgrade an Angular module or include it in the AngularJS application?
I found UpgradeAdapter.registerForNg1Tests and it solved this error. I love this function but the module UpgradeAdapter is said deprecated. I would like to use some alternative function which is not deprecated if exists.

Hybrid AngularJS/Angular 6 app module dependency issues

I'm currently exploring an upgrade path for a pretty large AngularJS 1.6 app to Angular 6. I have my app bootstrapping as a hybrid app, and I've begun converting individual modules and components. I need to be able to do the migration in chunks, though. It would be nice if I could migrate a module at a time, but I'm running into some issues, to that end.
I have a NavBar directive which resides in my core AngularJS module. That component is being downgraded with downgradeComponent and registered on the AngularJS core module. The landing AngularJS module has a dependency on the core module so that it can use the NavBar. This works fine, because the LandingComponent has also been converted to Angular6 and is being downgraded and registered on the landing AngularJS module.
There is a problem with using the NavBar component inside of any other AngularJS component, though. I have a third AngularJS module called workflows with a ViewWorkflows component that has a NavBar inside its template. When I navigate to that component, I get the following error:
angular.js:14791 Error: No component factory found for NavBarDirective. Did you add it to #NgModule.entryComponents?
I can fix this by converting and then downgrading ViewWorkflows, but since NavBar is being registered as a downgraded AngularJS component, shouldn't any AngularJS module that declares a dependency on the core module have access to it?
Code (Not runnable)
Edit: I've updated the gist to be a little more simple. The landing module is Angular, with an Angular component, <landing> that is downgraded to run on the AngularJS landing module and has a <t-nav-bar> inside it. It has a dependency on the core module which provides the downgraded <t-nav-bar> directive. The <test> component is an AngularJS component registered on the AngularJS landing module that cannot use the <t-nav-bar>. Without even bringing the workflows module into the situation, it doesn't work. What am I doing wrong?
I have managed to sort this out. I was trying to declare the NavBar as an Angular #Directive. It actually needs to be a #Component. After making that switch, it works exactly as expected.
I spun up this repo to test with, and discovered the issue there. It's a new Angular 6 app that I "downgraded" for experimenting.

Angular 2 syntax helpers for Angular 1.2

My application is in angular version 1.2. We are planning to make any new changes using typescript and angular 2 syntax helpers (like ng-metadata or angular2-now)
Unfortunately the above syntax helpers only works for angular version 1.4+. Is there any such helpers available for angular 1.2?
try this Angular-Typescript project on github, and my advice is to updated your project to 1.4 or above to make it easier for you!

angular 2 with modules from angular 1

Using angularjs 2 with typescript don't know how to use angular 1 modules like ui-grid or fullcalendar.
I can add module ui-grid with typescript?
Have a look at the migration guide:
AngularJS 1 to Angular 2 Upgrade Strategy
, and specifically this section: "Wrapping: AngularJS 1 to Angular 2"
You might also find this post useful: Angular 1 and Angular 2 integration: the path to seamless upgrade
PrimeNG provides FullCalendar integration and a DataTable, code is open source so you can review how the integration is done. DataTable is native though. http://www.primefaces.org/primeng/#/schedule

Use AngularJS (Angular1) module from Angular2 project

Just started a demo Angular2 project (no previous experience with Angular1/AngularJS. Have followed and extended from the online quickstart and tutorials, and all was fine. However I'm at the point where I would like to use some components from a library which is designed for AngularJS, and having no end of problems!
Most of the information available about AngularJS/Angular2 compatibility assumes that you have an AngularJS project that you're adding Angular2 components to - not the other way around - so what I'm hoping to do may not even be possible. What I've tried so far involves a simple stripped-back project based on the Angular2 quickstart, with a single Angular2 component that loads into the index.html. I'd then like to integrate components from the existing library (AngularJS-based) into this.
I've tried using UpgradeAdapter.upgradeNg1Component to create components from the library and add them directly into my Angular2 component
I've tried installing angularjs through npm, importing it in a script tag into my index.html and then using a combination of UpgradeAdapter.downgradeNg2Component and UpgradeAdapter.bootstrap to load my Angular2 as a downgraded module
Neither of these seem to work - the component fails to show, and the browser console tells me I've got an Uncaught SyntaxError: Unexpected token <
Evaluating http://localhost:3000/angular2/upgrade
Error loading http://localhost:3000/app/main.js
My best guess at the moment is that this is actually an unsupported scenario, and I need to have a 'proper' AngularJS app in order to use the UpgradeAdapter functionality from Angular2. Can anyone confirm this? Or is there something stupid I'm missing here?
Here is a working plunkr describing how to mix Angular1 and Angular2 elements:
http://plnkr.co/edit/yMjghOFhFWuY8G1fVIEg?p=preview
An important point is to bootstrap your main component on the UpgradeAdapter. This way all elements are available in providers (services / factories) and in directives (components / directives):
upgrade.bootstrap(document.body, ['heroApp']);
These two answers could help you:
angular 1.x and angular2 together
How to inject upgraded Angular 1 service/factory to Angular 2 component in ES5?
So the major problem in this case turned out to be the fact that it appears that the upgrade components aren't included as part of the basic angular 2 bundle. After adding:
<script src="node_modules/angular2/bundles/upgrade.min.js"></script>
to my index.html file the error I was seeing disappeared.
Thanks to the answer here for pointing me in the right direction!

Resources