I came across one issue related to injection (s) in Aurelia. I was wondering how to implement Validation, EventAggregator and Router without injection.
Below you can find an example that can give you a clear picture of the implementation and where I am stuck.
The class profile interacts with the view, and the AddressList object is created in the profile class, and this object (AddressList) interacts with the view.
For instance:
@inject(EventAggregator, Validation, Router)
export class Profile{
addressList: Array<AddressList> = [];
eventAgg:any;
_validation:any;
_router:any;
constructor(EventAggregator, Validation, Router )
{
this.eventAgg = EventAggregator;
this._validation = Validation;
this._router = Router;
this.addressList.push(new AddressList());
}
}
export class AddressList{
street1:string = "street1";
street2:string = "street2";
constructor(){
}
Now I want to implement addressList property checks without passing validation in the AddressList constructor
I do not want it
this.addressList.push(new AddressList(Valdiation));
Because it will create problems when I want to pass arguments in the AddressList constructor.
, , , .
,
/
, .
, AddressList undefined.
import { Factory } from 'aurelia-framework';
import { ObserverLocator } from 'aurelia-framework';
import { EventAggregator } from 'aurelia-event-aggregator';
import { Validation, ensure } from 'aurelia-validation';
@inject(EventAggregator, Validation, Factory.of(AddressList))
export class Profile{
addressList: Array<AddressList> = [];
eventAgg:any;
_validation:any;
_router:any;
constructor(EventAggregator, Validation, AddressList)
{
this.eventAgg = EventAggregator;
this._validation = Validation;
this.addressList.push(AddressList(["street1","street2"]));
}
}
@inject(Validation)
export class AddressList{
street1:string = "street1";
street2:string = "street2";
constructor(Validation, args){
this.street1=args[0];
this.street2=args[1];
}
}
AddressList
function() {
for (var _len = arguments.length, rest = Array(_len), _key = 0; _key < _len; _key++) {
rest[_key] = arguments[_key];
}
return container.invoke(_this2._…
AddressList ()

- Container.prototype._createInvocationHandler:
if (fn.inject === undefined)
fn undefined.
, , , .