this app have 2 components, the first have 2 inputs and the other have a table to show the values of a list. I want to pass the values of the inputs throught an event to the second component an insert the objects there. I can't push the code to the scratch org because of this error:
PROJECT PATH ERRORS
─────────────────────────────────────────────────────────── ───────────────────────────────────────────────
force-app\main\default\aura\crearCoche\crearCoche.cmp c:crearCoche:9,75: Invalid attribute "event"
force-app\main\default\aura\insertarCoche\insertarCoche.cmp c:insertarCoche:5,71: Invalid attribute "event"
THANKS!!
:::::HERE IS THE CODE:::::
MAIN APP
<aura:application>
<c:myComponent1/>
<c:myComponent2/>
<c:crearCoche/>
<aura:registerEvent name="passValueEvent" type="c:passValueEvent"/>
</aura:application>
FIRST COMPONENT
<div class="c-container">
<lightning:input type="number" aura:id="idCoche" label="Identificador Coche" />
<lightning:input type="text" aura:id="nombre" label="Nombre Coche" />
<lightning:button label="Introducir coche" onclick="{!c.crearCoche}"/>
<aura:handler event="c:passValueEvent" action="{!c.handleEvent}"/>
<br/>
<br/>
</div>
**CONTROLLER
**
({
crearCoche : function(component, event) {
var appEvent = $A.get("e.c:passValueEvent");
var nombre = component.find('nombre').get("v.value");
var id = component.find('idCoche').get("v.value");
appevent.setParams({"cocheID": nombre},{"cocheNAME":id});
console.log("firing event");
appEvent.fire();
}
})
SECOND COMPONENT
<aura:component>
<aura:attribute name="coches" type="List"></aura:attribute>
<div class="c-container">
<aura:handler event="c:passValueEvent" action="{!c.handleEvent}"/>
<table>
<tr>
<th>ID</th>
<th>Nombre</th>
</tr>
<aura:iteration var="coche" items="{!c.coches}">
<tr>
<td>{coche.id}</td>
<td>{coche.nombre}</td>
</tr>
</aura:iteration>
</table>
</div>
</aura:component>
CONTROLLER
({
createCar: function(nombre, color) {
var obj = new Object();
obj.nombre = nombre;
obj.color = color;
return obj;
},
insertCar: function(component, event) {
var objs = component.get('v.coches');
var appEvent = $A.get("e.c:passValueEvent");
var nombre = appEvent.getParam("cocheNAME");
var id = appEvent.getParam("cocheID")
objs.push(this.createCar(nombre,id));
component.set('v.objs', objs);
},
})
EVENT
<aura:event type="APPLICATION" description="Event template">
<aura:attribute name="cocheID" type="string"/>
<aura:attribute name="cocheNAME" type="string"/>
</aura:event>