Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/451.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 尝试编译和运行ionic2时出现空的白色屏幕_Javascript_Ionic Framework_Angular_Ionic2 - Fatal编程技术网

Javascript 尝试编译和运行ionic2时出现空的白色屏幕

Javascript 尝试编译和运行ionic2时出现空的白色屏幕,javascript,ionic-framework,angular,ionic2,Javascript,Ionic Framework,Angular,Ionic2,我正在尝试为我的登录页面创建一个简单的HTTP post服务 出于一些奇怪的原因,我在app.bundle.js中遇到了错误: TypeError:无法读取未定义的属性“toString” 未捕获的TypeError:无法读取未定义的属性“getOptional” 使用ionic2教程示例项目,我完成了以下工作: 在我的app.js中(这样我的服务可以在全球范围内访问) 并将根页面设置为我的登录页面 this.rootPage = LoginPage; 在我的log-In.html中 <

我正在尝试为我的登录页面创建一个简单的HTTP post服务

出于一些奇怪的原因,我在app.bundle.js中遇到了错误:

TypeError:无法读取未定义的属性“toString”

未捕获的TypeError:无法读取未定义的属性“getOptional”

使用ionic2教程示例项目,我完成了以下工作:

在我的app.js中(这样我的服务可以在全球范围内访问)

并将根页面设置为我的登录页面

this.rootPage = LoginPage;
在我的log-In.html中

 <button  class="button button-block" (click)="loginSuccess()" style="width:70%;">
   <strong>Log In</strong>
 </button>
httpService.JS

import { Inject } from 'angular2/core';
import { Http } from 'angular2/http';
import 'rxjs/add/operator/map';

export class httpService {
    static get parameters() {
        return [[Http]];
    }

    constructor(http) {
        this.http = http
    }

    loginService(httpService) {
      console.log("Service Function Variable: "+httpService);

    //  var body = "username=" + username + "&password=" + password+" &ipAddress="+ip;
      var body = "username=" + "admin" + "&password=" + "admin" +" &ipAddress="+"127.0.0.1";
      var headers = new Headers();
      headers.append('Content-Type', 'application/x-www-form-urlencoded');

      var url = 'http://localhost/WS/Login.asmx/Login';
      return this.http.post(url,body, {headers: headers}).map(res => res.json());

    }

}
正如你所看到的,我只是想提高我的服务水平。我看到的只是一个空白白屏和app.bundle.js(在编译时生成)中的错误,但我在编译时没有任何编译错误

出现错误的app.bundle.js代码为:

exports.isJsObject = isJsObject;
function print(obj) {
    console.log(obj);
}

我不知道这是自动生成的。我为代码转储(我试图删除不必要的东西)道歉,因为我不知道它的哪一部分出错了

我的爱奥尼亚版本是:2.0.0-beta.25,如果有帮助的话


非常感谢您的帮助。

查看了您的代码。我可以看到您使用了标题,但没有在代码中导入它们。在httpService.js文件中,修改import语句,如下所示

import { Http, Headers } from 'angular2/http';
app.bundle.js只是一个由webpack生成的模块包,它是Ionic使用的流行模块加载器

注:如果你想在你的Ionic 2应用程序中实现一个认证系统,我建议你看看


希望这对你有帮助。谢谢。

我在你的服务中没有看到decorator@Injectable

导出类httpService{

应该是(我想,我使用的是v24,可能在v25中有所不同?)

从“angular2/core”导入{Injectable,injecte}

@注射的
导出类httpService{

@A_Singh在爱奥尼亚2中,这意味着应用程序级别?我不是很确定。这是一个由爱奥尼亚实现的自定义装饰程序。不管怎样,这没关系,可能还有其他的事情,所以,这是一个了解你要做什么的好地方:添加,删除app.js中的提供程序,然后将其添加到log-in.js中。
exports.isJsObject = isJsObject;
function print(obj) {
    console.log(obj);
}
var inits = injector.getOptional(application_tokens_1.APP_INITIALIZER);
import { Http, Headers } from 'angular2/http';