Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/435.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 Angular2:Index.html不';t显示文件,仅显示“t”;“正在加载…”;_Javascript_Html_Angular - Fatal编程技术网

Javascript Angular2:Index.html不';t显示文件,仅显示“t”;“正在加载…”;

Javascript Angular2:Index.html不';t显示文件,仅显示“t”;“正在加载…”;,javascript,html,angular,Javascript,Html,Angular,我不确定如何将文件绑定到“我的应用”选择器。 以下是plnkr链接: 编辑:我认为如果我将模板代码放在index.html文件的标记中,plunker可以显示一些内容 我想知道是否有人知道如何将模板url附加到index.html文件,以便它显示模板url而不是“加载…” index.html文件: <!DOCTYPE html> <html> <head> <script>document.write('<base href=

我不确定如何将文件绑定到“我的应用”选择器。 以下是plnkr链接:

编辑:我认为如果我将模板代码放在index.html文件的标记中,plunker可以显示一些内容

我想知道是否有人知道如何将模板url附加到index.html文件,以便它显示模板url而不是“加载…”

index.html文件:

<!DOCTYPE html>
<html>
  <head>
    <script>document.write('<base href="' + document.location + '" />');</script>
    <title>Angular 2 Tour of Heroes</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="styles.css">

    <!-- Polyfill(s) for older browsers -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.0/es6-shim.min.js"></script>

    <script src="https://npmcdn.com/zone.js@0.6.12?main=browser"></script>
    <script src="https://npmcdn.com/reflect-metadata@0.1.3"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.27/system.js"></script>
    <script src="https://npmcdn.com/typescript@1.8.10/lib/typescript.js"></script>

    <script src="systemjs.config.js"></script>
    <script>
      System.import('app').catch(function(err){ console.error(err);  });
    </script>
  </head>

  <body>
    <my-app>Loading...</my-app>
  </body>
</html>


<!-- 
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
-->

文件。写(“”);
角2英雄之旅
System.import('app').catch(函数(err){console.error(err);});
加载。。。
.ts文件

import {Component, OnInit} from 'angular2/core';
import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
import {Hero} from './hero';
import {HeroService} from './hero.service';
import {Observable} from'rxjs/Rx'



@Component({
  selector: 'my-app',
  templateUrl: 'app/biddingPage.component.html',
  styleUrls: ['app/BiddingPage.component.css'],
  providers: [HeroService],
  directives: [ROUTER_DIRECTIVES]
})



export class BiddingPageComponent{
   numberofbids = 0;
    slot1 = 0;


myFunction(slotvalue) 
 {
        this.slot1 = slotvalue;
        this.numberofbids +=1;

 }
  ngOnInit(ticks){
    let timer = Observable.timer(2000,1000);
    timer.subscribe(t=>this.ticks = t);
  }

  upgradeTime = 172801;
  ticks = this.upgradeTime;
timer(days, hoursLeft, minutesLeft, remainingSeconds) {
    days        = Math.floor(this.ticks/24/60/60);
    hoursLeft   = Math.floor((this.ticks) - (days*86400));
    var hours       = Math.floor(hoursLeft/3600);
    minutesLeft = Math.floor((hoursLeft) - (hours*3600));
    var minutes     = Math.floor(minutesLeft/60);
    remainingSeconds = this.ticks % 60;
    if (remainingSeconds < 10) {
        remainingSeconds = 0 + remainingSeconds; 
    }
    document.getElementById('countdown').innerHTML = days + ":" + hours + ":" + minutes + ":" + remainingSeconds;
    if (this.ticks == 0) {
        clearInterval(this.countdownTimer);
        document.getElementById('countdown').innerHTML = "Completed";
    } else {
        this.ticks--;
    }
}
 countdownTimer = setInterval('timer()', 1000);

}
从'angular2/core'导入{Component,OnInit};
从“angular2/ROUTER”导入{RouteConfig,ROUTER_指令};
从“/Hero”导入{Hero};
从“/hero.service”导入{HeroService};
从'rxjs/Rx'导入{Observable}
@组成部分({
选择器:“我的应用程序”,
templateUrl:'app/biddingPage.component.html',
样式URL:['app/BiddingPage.component.css'],
提供者:[服务],
指令:[路由器指令]
})
导出类BiddingPageComponent{
numberofbids=0;
slot1=0;
myFunction(slotvalue)
{
this.slot1=slotvalue;
此参数为1.numberofbids+=1;
}
恩戈尼尼特(蜱类){
设定时器=可观测定时器(20001000);
timer.subscribe(t=>this.ticks=t);
}
升级时间=172801;
滴答声=这个。升级时间;
计时器(天、小时、分钟、剩余秒){
天数=数学楼层(此为.ticks/24/60/60);
hoursLeft=数学地板((this.ticks)-(days*86400));
var小时=数学楼层(左小时/3600);
分钟左=数学楼层((小时左)-(小时*3600));
var分钟=数学楼层(左分钟/60);
remainingSeconds=this.ticks%60;
如果(剩余秒数<10){
剩余秒数=0+剩余秒数;
}
document.getElementById('countdown').innerHTML=days+“:“+hours+”:“+minutes+”:“+remainingSeconds;
如果(this.ticks==0){
clearInterval(这个是倒计时);
document.getElementById('countdown').innerHTML=“已完成”;
}否则{
这是“滴答声”;
}
}
倒计时=设置间隔('timer()',1000);
}

您的配置文件有点乱

将文件目录从
src
更改为
app
。对于例如
src/main.ts
app/main.ts

index.html
脚本标记更改为

<script>
    System.import('app').catch(function(err){ console.error(err);  });
</script>

您的plunker和代码有一些错误,这里是一个干净的

这是如何在angular 2组件中指定templateUrl和StyleUrl

@Component({

 selector: 'my-app',
 templateUrl:"src/app.component.html",
 styleUrls: ['src/app.component.css'],


 })

要更改plunker中的目录或文件名,只需双击它。

我仍然会收到“加载…”消息。我是删除index.html文件中的所有其他脚本还是保留它们?您是否也更改了
app.ts
的目录?从
src/app.ts
app/app.ts
目录位于配置文件的哪一行?如何更改目录
@Component({

 selector: 'my-app',
 templateUrl:"src/app.component.html",
 styleUrls: ['src/app.component.css'],


 })