I get the following error "ReferenceError: printStackTrace is not defined",
when I tried to use StackTrace in my angular aplication.
stacktrace.js changed the API for v1.0.
You'll want to use
var callback = function(frames) { console.log(frames); };
var errback = function(err) { console.log(err.message); };
StackTrace.get().then(callback).catch(errback);
as suggested by the docs.
If all you want to do is parse an Error you can just use error-stack-parser
Please refer to the v0.x -> v1.x migration guide if you were using the old version.
By the way, if you need to use version 0.x you can find it in the stable branch on GitHub
Related
Recently we have updated our application to angular 1.3.20 version. But after the upgradation the existing code is throwing angular error.
app.controller('searchController', ['$scope','TemplateViewService','$http','SearchService','$browser','$rootScope','$state','$location', '$uibModal','ReadConfigurationService','$filter','SpinnerService','$log', function($scope,TemplateViewService,$http,SearchService,$browser,$rootScope,$state,$location, $uibModal,ReadConfigurationService,$filter,SpinnerService,$log){//PA1501-1206
var productType = undefined;
//PA1501-2173 start
$scope.dataList = SearchService.getDataList();
$scope.dataListCopy = SearchService.getDataListCopy();
$scope.deleteList = [];
$scope.displayArtifactList=[];
};
Here at this line I am getting Angular Js error Unknown provider TemplateViewService <- searchController.
Can anyone please suggest, how to resolve this error.
This is happening because of TemplateViewService js file is not getting compiler, please make sure it again....
I'm trying to generate some random data for my e2e tests. Seems that the only library I found was chance.js. But can't make it works. This is what I've tried so far:
describe('In the login page', function () {
var chance = new Chance(); // ReferenceError: Chance is not defined
}
Then adding
beforeEach(function(){
browser.executeScript(
function() {
return chance;
}).then(function(_chance){
chance = _chance; //It returns an object, but can't use any of the methods.
});
});
But if I try
beforeEach(function(){
browser.executeScript(
function() {
return chance.email(); //Note this line here
}).then(function(_chance){
chance = _chance; //It returns an email
});
});
Thats all I have so far... any clue/idea?
First, install chance.js in your project:
npm install chance --save-dev
This installs chance.js as a node module in your project. Then include it in your spec and instantiate:
var chance = require('../node_modules/chance').Chance();
Then call in your spec. For example:
it('should add a new friend', function() {
var friendName = chance.string()
friendPage.addFriend(friendName);
expect(friendPage.inResults(friendName)).toBeTruthy();
});
Hope that helps...
Okay first you need to download chance.js and add that file to your html directory
Second add script src="chance.js" in a proper script tag your section
Within another script tag you should be able to use any of the functions that are listed on the website
working jsfiddle: http://jsfiddle.net/c96x2cpa/
fiddle js code:
alert(chance.bool());
alert(chance.character());
alert(chance.floating());
It was easy at the end :)
You just need to install chance as a node module.
npm install chance
Then require the node in the spec
// Load Chance
var Chance = require('chance');
And use it where ever you want
chance.email()
Enjoy!
I'm pretty new to Angular. I'm trying to incorporate the openPGP library to my app (client side). I need some help on how to incorporate a javascript library to the Angular App. Thanks!
I'm reading through the openPGP docs https://github.com/openpgpjs/openpgpjs
and the example provide in the docs is below:
var openpgp = require('openpgp');
var key = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----';
var publicKey = openpgp.key.readArmored(key);
var pgpMessage = openpgp.encryptMessage(publicKey.keys, 'Hello, World!');
I prefer not to use require to source in openPGP to my app. So I've tried
var openpgp = window.openpgp; which seems to not throw any error here. However, I get TypeError: Cannot read property 'key' of undefined error.
I should mention that I have installed openpgp using bower install.
I'm still trying to figure out what I can do to refer to openPGP in the Angular app. Thanks.
If you're on the client-side, use a script tag, like
<script src="/path/to/openpgp.js"></script>
instead of require()
In Angular 1.2.0, there is this funny comment:
// IE stupidity! (IE doesn't have apply for some native functions)
It sits on line 9835 in the functionCall function:
functionCall: function(fn, contextGetter) {
var argsFn = [];
if (this.peekToken().text !== ')') {
do {
argsFn.push(this.expression());
} while (this.expect(','));
}
this.consume(')');
var parser = this;
return function(scope, locals) {
var args = [];
var context = contextGetter ? contextGetter(scope, locals) : scope;
for (var i = 0; i < argsFn.length; i++) {
args.push(argsFn[i](scope, locals));
}
var fnPtr = fn(scope, locals, context) || noop;
ensureSafeObject(context, parser.text);
ensureSafeObject(fnPtr, parser.text);
// IE stupidity! (IE doesn't have apply for some native functions)
var v = fnPtr.apply
? fnPtr.apply(context, args)
: fnPtr(args[0], args[1], args[2], args[3], args[4]);
return ensureSafeObject(v, parser.text);
};
},
I believe it is causing me pain, but no errors are thrown so I'm having a hard time seeing exactly what native function it might be trying (and failing) to call apply on. Ever since I implemented $q library to use promises to handle async REST calls, IE9 doesn't even make an attempt to call the services (according to the network tab in dev tools). Instead, the promise is immediately rejected. I tried googling for an answer, and looking at angular's docs on using IE, but I'm getting nowhere.
Has anyone had a similar issue with getting promises to work on IE9 using angular's "q-lite"? Does anyone know what this silly comment is referring to specifically?
I believe I figured it out through a ton of trial and error. It seems the issue, in my case, was that I was using the built-in q library for promises... specifically q.all([]):
$q.all([
firstRequest.$promise,
secondRequest.$promise,
thirdRequest.$promise,
moreRequets.$promise
]).then(function() {
//do stuff
});
While I still have not found out what specific operations the angular code refers to when it says some native functions, I found that the docs for function.apply() have the following caveat:
Note: Most browsers, including Chrome 14 and Internet Explorer 9, still do not accept array-like objects and will throw an exception.
Whatever the specifics, removing my reference to $q.all solved it for me. I hope this helps anyone who has this issue in the future. If someone happens to encounter another case where this IE behavior chokes up angular, perhaps they would be so kind as to comment below or add an answer.
FYI, I am currently at angular 1.2.14.
How can I apply animation in ui-views?
I found the code
// Unfortunately there is no neat way to ask $injector if a service exists
var $animator; try { $animator = $injector.get('$animator'); } catch (e) { /* do nothing */ }
But how can I inject an animator?
This is not a relevant question. If you're using a sufficiently recent version of AngularJS (i.e. 1.1.5), it works by itself.
See the documentation for details: https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-animate-ui-view-with-ng-animate