AngularJS $sce.getTrustedResourceUrl(templateUrl) error - javascript

I am working on a simple application in RhoMobile and I am using AngularJS with it.
When defining routeProvider, I have come to the strangest issue I have seen.
I tried many things, like chaning the path for templateUrl defining an explicit one, but with no success. But if I use template property instead of templateUrl it works.
I am getting this error:
Error: 'undefined' is not a function (evaluating '$sce.getTrustedResourceUrl(templateUrl)')
I am using AngularJS v1.2.16 and I am out of ideas.
EDIT: I set up an example RhoMobile application with angular-seed which has the error, you can find the application here
UPDATE:: I got reply from RhoMobile core developers that this will be fixed in 4.2

It works just fine when served statically, so RhoMobile is probably screwing up the origins, and running your app into CORS issues.
git clone https://github.com/TheCodeDestroyer/rhomobile-angular
cd rhomobile-angular/
python -m SimpleHTTPServer
open "http://localhost:8000/public"
# click around... it works!

Indeed, issue has no any relation to rhomobile code. Rhomobile used opal.rb/opal.js conflicted with angular.js until RMS4.2. Started from RMS4.2 opal.js is not in use anymore. So there may be another reason for your issue.
In case you run your application using RhoSimulator on windows it may be a bug with toLowerCase() method of String class. It looks like the bug is in the QTWebView component used for RhoSimulator. Just discovered it and fix is in the progress. Issue appears only on windows. On Mac OS X everything performing correctly.
Try to evaluate following expression in web console of RhoSimulator:
"RESOURCE_URL".toLowerCase()
In case it evaluates as "resource url" the angular.js will not work.
Watch for update in your RhoMobile support ticket.

It doesn't look like you're including the ngSanitize module.

Related

Testing Angularjs locators

Kind of getting desperate here.
I have a legacy testsuite using AngularJS (5.4.1) driven by Node 8.12.0.
I want to debug some tests but it seems impossible.
Control flow is enabled in the tests, so I followed the docs on the protractor website. Sadly, it does not work.
browser.pause() just get skipped and using browser.debugger() is deprecated from Node 8.
I decided to disable the control flow but I ran into another problem.
We go to a login page before accessing the application, and the angular debugger does not like that. When accessing the non-angular page, the debugger just quits, stating that angular is not defined.
I then turned to Google to see if there are any Chrome extensions that enable me to use the dev tools to test the locators, but to no avail.
Would be great if I can get the debugger working.
Thanks in advance.
Regards
Here is a setup for IntelliJ
(working directory is example)

ionic2 not loading javascript import in UWP app

I have an ionic2 app that works great in the browser however when I try to run it as a UWP app it fails with the following error:
JavaScript runtime error: Uncaught (in promise): Error: Error in :0:0 caused by: 'Oidc' is undefined
I'm using an oidc library in just one class so I went and looked there and I have the following:
import * as Oidc from 'oidc-client';
This seems to work fine when running the app in the browser but it doesn't seem to get picked up when run as an app. I don't know if this is a ionic build issue/ webpack / or most likely just my ignorance since i'm relying on a lot of pieces I don't fully understand.
I fixed this issue by directly referencing the script in my index.html file:
<script src="oidc-client.min.js"></script>
but that really seems like the wrong solution. Can someone point me in the right direction? I want to understand why my import sometimes works.
edit: Also no errors made it back to ionic cli. I had to load this up in Visual Studio to find the problem
I can't say for sure since I'm not familiar with Oidc, but sometimes doing 'import *' or 'export ' can break things when working with ionic 2 or just straight up angular 2. I think it's more of a webpack related issue. We've had weird build issues or stupid 'X is undefined' issues in our development and oftentimes it's been related to using the wildcards (I think technically they're called barrels?). Also, some libraries don't play nicely with ES6 modules, although that might not be your case since it runs fine in the browser. Once though I had a really small use case for jquery in an angular 2 app, and the only way to get it in the app was by sticking a link in the index.html. But my gut tells me your problem is with the import statement.

Meteorjs + Angular 2

I am attempting the Meteor/Angular2 tutorial here
If I make a change to a component the changes are not updated in the browser (Google Chrome); even if I do the following things...
Save changes and hard refresh browser.
Stop server and restart.
I have to clear the browser cache to get rid of the old data and load the new.
I'm pretty sure this should not be the case, as it creates a major problem for a developer.
This tutorial is using Angular2, Meteorjs, as well as a typescript compiler.
This is not an Angular issue.
My question is... Is the problem with meteorjs not triggering a hard refresh? Or could it perhaps be an issue with the typescript compiler?
Also, how could I fix this?
I'm running
Typescript Compiler: netanelgilad:angular2-typescript
Meteorjs: 1.2.2
Google Chrome: Version 47.0.2525.0 canary (64-bit)
UPDATE:
I tried a normal .js file and everything works as expected. This means its the Typescript Compiler: netanelgilad:angular2-typescript.
I'll check out the package and see what I can find.
If You are using
http-server
then this may be the issue of http-server as it always store the data in cache.
In my case i was using http-server and this problem occured.
You can fix it by selecting the disable cache option in developer tools(chrome).

Ember Run Loop in testing mode

I'm using https://github.com/ride/ember-stripe-service add-on and everything worked nicely until Ember 1.10.1, but since Ember 1.11.0 Ember's run loop start crashing in E2E testing saying that we were trying to access a destroyed object, I have been trying to fix it but I couldn't so I made a PR https://github.com/ride/ember-stripe-service/pull/32 reproducing the error in tests/dummy and tests/integration but neither they know how to fix it, please help.
We think is something related with Stripe.js (https://js.stripe.com/v2/) because they embed an Iframe when the script in loaded in the browser.

How does one diagnose errors in a controller?

I'm trying to get up to speed with AngularJS, coming from a Java background, not Javascript. I'm used to stepping into a debugger with Eclipse, MSDEV, etc, but not so much used to Google Chrome's dev tools or WebStorm (which I intend to use). Occasionally, I've made a mistake that apparently is detected upon startup. I'm guessing it's logged someplace (I hope!), and then silently continues. Then when I go to the page that would use the controller, I get the
Argument 'MyController' is not a function, got undefined
error. Of course, the attached stack trace isn't very helpful. So the big question is: how do you step into this mess when it actually finds the problem inside the controller, not later when it actually tries to use the controller?
I could post today's issue, but I'd rather have the tools to diagnose this myself than just solve the problem for today.
Install angularJS batarang chrome extension.
Go through github repository of angularJS-batarang
This extension is nice and we can easily debug the angularJS applications
About your error : possible duplicate of AngularJS/Jade Error: Argument 'MyController' is not a function, got undefined (MEAN)

Categories