I just started to play with AngularJS and I got error below.
Error: Argument '?' is not a function, got Object
at assertArg (http://localhost/angular/project/scripts/vendor/angular.js:1039:11)
at assertArgFn (http://localhost/angular/project/scripts/vendor/angular.js:1049:3)
at http://localhost/angular/project/scripts/vendor/angular.js:4802:9
at http://localhost/angular/project/scripts/vendor/angular.js:4384:17
at forEach (http://localhost/angular/project/scripts/vendor/angular.js:137:20)
at nodeLinkFn (http://localhost/angular/project/scripts/vendor/angular.js:4369:11)
at compositeLinkFn (http://localhost/angular/project/scripts/vendor/angular.js:4015:15)
at compositeLinkFn (http://localhost/angular/project/scripts/vendor/angular.js:4018:13)
at publicLinkFn (http://localhost/angular/project/scripts/vendor/angular.js:3920:30)
at update (http://localhost/angular/project/scripts/vendor/angular.js:14202:11)
Now, my question is: Is there a way I can find line in .js file where error occurred?
I get line number in angular.js file on raised exception but there is too many files where
error can occur.
I tried with AngularJS Batarang, but this is more for debugging semantic not syntax errors.
Thanks.
It'll be easier if you link to the js files that would have caused this error.
From the angular.js source, https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js
it looks like a problem with instantiating the controller.
Here's the line that's causing assertion failure:
/**
* #ngdoc function
* #name ng.$controller
* #requires $injector
*
* #param {Function|string} constructor If called with a function then it's considered to be the
* controller constructor function. Otherwise it's considered to be a string which is used
* to retrieve the controller constructor using the following steps:
*
* * check if a controller with given name is registered via `$controllerProvider`
* * check if evaluating the string on the current scope returns a constructor
* * check `window[constructor]` on the global `window` object
*
* #param {Object} locals Injection locals for Controller.
* #return {Object} Instance of given controller.
*
* #description
* `$controller` service is responsible for instantiating controllers.
*
* It's just a simple call to {#link AUTO.$injector $injector}, but extracted into
* a service, so that one can override this service with {#link https://gist.github.com/1649788
* BC version}.
*/
return function(constructor, locals) {
if(isString(constructor)) {
var name = constructor;
constructor = controllers.hasOwnProperty(name)
? controllers[name]
: getter(locals.$scope, name, true) || getter($window, name, true);
======> assertArgFn(constructor, name, true);
}
return $injector.instantiate(constructor, locals);
};
It's unable to find the constructor for the controller.
Related
currently i'm struggle with the identifier because i not need it.
i only need an get request without anything and returning some system infos.
/**
* #ApiResource(
* itemOperations={
* "info"={
* "method"="GET",
* "path"="/system/info",
* "controller"=GetInfo::class,
* "read"=false
* }
* },
* collectionOperations={
*
* }
* )
*/
thats my current config but it always requires an identifier.
It sounds as if you're after not an ApiPlatform resource, but simply a standard endpoint.
Have a look at this documentation from Symfony on how to define a route.
To me it sounds like you're after something like this:
config/routes.yaml
system_info:
path: /system/info
method: GET
controller: App\System\Info
With controller:
namespace App\System;
class Info
{
public function __invoke(): JsonResponse
{
return new JsonResponse(['pc' => 'master race']);
}
}
Remember that ApiPlatform is supposed to be working with Resources (aka: DTO's and Entities), and as you're use-case does not do either, you end up struggling to make it work.
Oke, so I have the following use case. On some of my entities I use a file entity for example with the organization logo.
Now I want users to post either a link (I will then async get the file) or a base64 has of the file. But when the user does a get I want to present an JSON representation of the file entity (that also includes size, a thumbnail link etc).
The current setup that I have is two different properties on my entity, one for reading and one for posting with different logic. And then an event listener that handels the logic. That’s all fine and all but it causes the user to post a postLogo property in their json file, I would hower like them to post to a logo property in their json file.
Is there an annotation that I can use (for example name on ApiProperty) to achieve this or do I need to override the serializer?
/**
* #var File The logo of this organisation
*
* #ORM\ManyToOne(targetEntity="File")
* #ApiProperty(
* attributes={
* "openapi_context"={
* "type"="#/components/schemas/File"
* }
* }
* )
* #Groups({"read"})
*/
public $logo;
/**
* #var string The logo of this organisation, a logo can iether be posted as a valid url to that logo or a base64 reprecentation of that logo.
*
* #ApiProperty(
* attributes={
* "openapi_context"={
* "type"="url or base64"
* }
* }
* )
* #Groups({"write"})
*/
public $postLogo;
You can add a setter with a SerializedName annotation. Something like this should work
/**
* #Groups({"write"})
* #SerializedName("logo")
*
*/
public function setPostLogo($value)
{
$this->postLogo = $value;
}
I'm doing the application with the Spring Integration Java DSL.
What is the best way to log to the database using the Spring Data JPA from the application?
I have a quite long integration flow with the multiple HTTP gets and posts. I want at least log the sent and responded messages and which URLs were used and possible some other custom values.
I have tried the logging with the method IntegrationFlowBuilder.log. With that my plan would be create some custom logger, which logs to the database.
I have tried the method IntegrationFlowBuilder.enrichHeaders with the method IntegrationFlowBuilder.log to log the URLSs and the other custom values. How to change some header entry inside the IntegrationFlowBuilder? I have added the entry with same key and different value, but the value in the logging doesn't change.
The HeaderEnricherSpec for the enrichHeaders() provides an option like:
/**
* Determine the default action to take when setting individual header specifications
* without an explicit 'overwrite' argument.
* #param defaultOverwrite the defaultOverwrite.
* #return the header enricher spec.
* #see HeaderEnricher#setDefaultOverwrite(boolean)
*/
public HeaderEnricherSpec defaultOverwrite(boolean defaultOverwrite) {
Also each added entry into the headers can be specified with their own override flag:
/**
* Add a single header specification where the value is a String representation of a
* SpEL {#link Expression}.
* #param name the header name.
* #param expression the expression.
* #param overwrite true to overwrite an existing header.
* #return the header enricher spec.
*/
public HeaderEnricherSpec headerExpression(String name, String expression, Boolean overwrite) {
I have successfully implemented the onUserAuthenticate event to implement my custom authentication API inside the Joomla! site that I am working on.
Now I want to also have some custom code run on the onUserLogout event.
I have added the following code to the custom authentication plugin file.
But this method is not getting fired/invoked while the previous one(onUserAuthenticate) is working just fine.
/**
* Method to handle the SSO logout
*
* #param array $user Holds the user data.
* #param array $options Array holding options (client, ...).
*
* #return boolean Always returns true.
*
* #since 1.6
*/
public function onUserLogout($user, $options = array()) {
if (JFactory::getApplication()->isSite()) {
// Set the cookie to expired date.
setcookie('customAuth', '123', time() - (60 * 60 * 24 * 365), '/', '.customdomain.org');
}
return true;
}
Okay so I was getting it all wrong.
So I was adding the aforementioned method inside the same plugin file that handled the onUserAuthenticate.
For Joomla! the login is a separate process which has its respective events like onUserAuthenticate.
But it seems like the event onUserLogout has to be inside the plugin with the type of user.
So I created a separate plugin inside the user plugin type directory, installed it, and enabled it....And voila!! it worked.
This had me scratching my head for quite a while.
I made a subclass of goog.ui.Button in my Google Closure javascript.
/**
* #fileoverview This button makes a new widget.
* #author David Faux
*/
goog.provide('app.ui.NewWidgetButton');
goog.require('goog.ui.Button');
/**
* Button for creating a new widget.
* #constructor
* #param {goog.ui.ButtonRenderer=} opt_renderer Optional renderer used to
* render or decorate the button.
* #param {goog.dom.DomHelper=} opt_domHelper Optional DOM hepler, used for
* document interaction.
* #extends {goog.ui.Button}
*/
app.ui.NewWidgetButton = function(opt_renderer, opt_domHelper) {
goog.base(
this,
/** #type {goog.ui.ControlContent} */ 'New Widget',
opt_renderer,
opt_domHelper);
}
goog.inherits(app.ui.NewWidgetButton, goog.ui.Button);
However, when I instantiate this button with var newButton = app.ui.NewWidgetButton();, I get an error in Chrome Console:
`Uncaught TypeError: Object #<Object> has no method 'setContentInternal'`
I looked up the method setContentInternal, and it seemed to be a method of the class goog.ui.Control, which is a superclass of goog.ui.Button, so I am befuddled as to why this method is undefined.
The instantiation of newButton is missing the new keyword. Adding the new keyword fixes the error.
var newButton = new app.ui.NewWidgetButton();
Set the Closure Compiler flag --warning_level=VERBOSE to generate an error such as the following:
WARNING - Constructor function (new:app.ui.NewWidgetButton, (goog.ui.ButtonRenderer|null)=, (goog.dom.DomHelper|null)=): undefined should be called with the "new" keyword