Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.83 KB | None | 0 0
  1. ERROR Error: Uncaught (in promise): Error: Modal content has more than one root view.
  2. JS: Error: Modal content has more than one root view.
  3.  
  4. onLogin()
  5. {
  6. if(this.loading)
  7. return;
  8.  
  9. this.loading=true;
  10. let options: ModalDialogOptions = {
  11. viewContainerRef: this.vcRef,
  12. context:null,
  13. fullscreen: false
  14. };
  15. console.log("Vamos a entrar en login");
  16. this._modalService.showModal(ViewLogin, options)
  17. .then((userResult: User) => {
  18. if(userResult!=null)
  19. {
  20. console.log("ENTRA el user = Object." + userResult.nombre);
  21. this.usuario=userResult;
  22. this.res["login"]=userResult;
  23. app.setResources(this.res);
  24. }
  25. console.log("ENTRA en el USER = NULLLLL");
  26. this.loading=false;
  27. }).catch((error)=>{this.loading=false; alert(error);});
  28. }
  29.  
  30. import { Component, OnInit } from "@angular/core";
  31. import { User } from "../../Model/User/user";
  32. import {UserService} from "../../Model/User/user.service"
  33. import { Page } from "tns-core-modules/ui/page";
  34. import aplicacion = require("tns-core-modules/application");
  35. import aplicacionSet=require("tns-core-modules/application-settings");
  36. import { ModalDialogParams } from "nativescript-angular/modal-dialog";
  37. import { SelectedIndexChangedEventData } from "nativescript-drop-down";
  38.  
  39.  
  40. @Component({
  41. selector: "login",
  42. providers: [UserService],
  43. templateUrl: "./modal/login/login.html",
  44. styleUrls: ["./modal/login/login-common.css"]
  45. })
  46.  
  47. export class ViewLogin implements OnInit {
  48. user: User;
  49. estadoLog="";
  50. clave="";
  51.  
  52. loading=false;
  53. public selectedIndex=0;
  54. public dependientes: Array<string>=[];
  55.  
  56.  
  57. constructor(
  58. private params:ModalDialogParams,
  59. private userService:UserService,
  60. private page:Page)
  61. {
  62. console.log("entrando en login");
  63. this.user=new User(null);
  64. this.user.usuario="";
  65. this.user.clave="";
  66. this.userService.listar().subscribe(
  67. (res:Array<User>)=>{
  68. res.forEach(element => {
  69. this.dependientes.push(element.usuario);
  70. });
  71. this.selectedIndex=0;
  72. console.log("ADENTRO DE LA FUNCION SUBSCRIBE ----- " + res.length);
  73. },
  74. (error)=>{
  75. console.log("Error al hacer LOGIN: " + error);
  76. });
  77.  
  78. this.page.on("unloaded", () => {
  79. this.params.closeCallback(null);
  80. });
  81. console.log("DESPUES DEL page.on");
  82. }
  83.  
  84. public onchange(args: SelectedIndexChangedEventData) {
  85. console.log('El usuario selecionado es ' + this.dependientes[args.newIndex] + " new-> " + args.newIndex + " select-> " + this.selectedIndex);
  86. this.user.usuario=this.dependientes[args.newIndex];
  87. }
  88.  
  89. teclado(numero:string)
  90. {
  91. if(numero=='back')
  92. this.user.clave=this.user.clave.substring(0,this.user.clave.length-1);
  93. else
  94. this.user.clave+=numero;
  95. this.clave= Array(this.user.clave.length+1).join("*") ;
  96. }
  97.  
  98. ngOnInit()
  99. {
  100.  
  101. this.page.actionBarHidden=true;
  102. if(aplicacionSet.hasKey("usuario"))
  103. this.user.usuario=aplicacionSet.getString("usuario");
  104.  
  105. }
  106.  
  107. summit(){
  108. if(this.loading)
  109. return;
  110. this.loading=true;
  111. this.estadoLog="";
  112. var res=aplicacion.getResources();
  113. this.userService.login(this.dependientes[this.selectedIndex],this.user.clave).subscribe(
  114. (resultado:User)=>
  115. {
  116. if(resultado==null)
  117. {
  118. console.log("Login incorrecto: " + resultado);
  119. this.estadoLog="Login incorrecto"
  120. res["login"]=null;
  121. aplicacion.setResources(res);
  122. this.loading=false;
  123. return false;
  124. }
  125. else
  126. {
  127. this.estadoLog="Login correcto";
  128. res["login"]=resultado;
  129.  
  130. aplicacion.setResources(res);
  131. aplicacionSet.setString("usuario",this.user.usuario);
  132. console.log("lo hemos logrado: " + resultado.nombre);
  133. console.log("login correcto");
  134. this.params.closeCallback(resultado);
  135. this.loading=false;
  136. return true;
  137. }
  138. },
  139. (error)=>
  140. {
  141. console.log("No ha hecho login: " + error);
  142. this.estadoLog = "Login incorrecto";
  143. res["login"]=null;
  144. aplicacion.setResources(res);
  145. this.loading=false;
  146. return false;
  147. }
  148. );
  149.  
  150. }
  151.  
  152. volver()
  153. {
  154. this.params.closeCallback(null);
  155. }
  156. }
  157.  
  158. JS: ERROR Error: Uncaught (in promise): Error: Modal content has more than
  159.  
  160. one root view.
  161. JS: Error: Modal content has more than one root view.
  162. JS: at `file:///data/data/org.adealoxica.picking/files/app/tns_modules/nativescript-angular/directives/dialogs.js:99:23 [angular]`
  163. JS: at Object.onInvoke `(file:///data/data/org.adealoxica.picking/files/app/tns_modules/@angular/core/bundles/core.umd.js:17343:37) [angular]`
  164. JS: at `file:///data/data/org.adealoxica.picking/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:883:34 [angular]`
  165. JS: at Object.onInvokeTask `(file:///data/data/org.adealoxica.picking/files/app/tns_modules/@angular/core/bundles/core.umd.js:17334:37) [angular]`
  166. JS: at drainMicroTaskQueue `(file:///data/data/org.adealoxica.picking/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:595:35) [angular]`
  167. JS: at ZoneTask.invokeTask `(file:///data/data/org.adealoxica.picking/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:500:21) [angular]`
  168. JS: ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement