草庐IT

javascript - 无法获取/页面 Angular 2 路由错误

我已经设置了在应用程序中完全正确工作的Angular路由,但是如果我导航到我的关于页面,例如http://localhost:9000/about并刷新页面我收到错误提示"CannotGET/about",如果我打开一个新选项卡并将url粘贴到那里并访问该页面,也会发生同样的情况。我的boot.ts文件包含路由逻辑//--Typescripttypings-------------------------------------------------------////////Imports-----------------------------------------------

javascript - Angular 2 : How to apply a callback when I leave a route

这是例子,我在AppComponent中定义了一些路由:@RouteConfig([{path:'/',name:'Index',component:IndexComponent,useAsDefault:true},{path:'/:id/...',name:'User',component:UserComponent},{path:'/plan',name:'Plan',component:PlanComponent},{path:'/foo',name:'Foo',component:FooComponent}]}在UserComponent中,我定义了另一条路由,如下所示:@R

javascript - Angular2 Routing - 将数据从父组件传递到子子组件

我正在尝试将一个简单的字符串对象从父组件传递到子子组件。我尝试通过以下方式进行:parent.tsimport{Component}from'angular2/core';import{Router,ROUTER_DIRECTIVES,ROUTER_PROVIDERS,RouteConfig}from'angular2/router';import{ChildCmp}from"./child";import{bootstrap}from'angular2/platform/browser';@Component({selector:'app',template:``,directive

javascript - Angular 2 RC 4 "(SystemJS) Can' t 解析 [object Location] : "in IE 11 的所有参数

我的Web应用程序在Chrome、Firefox和Edge中运行良好,但在IE11中当然不行。可能也不是旧版本的IE。它是一个使用AngularCli生成应用程序的最小应用程序。完整错误:EXCEPTION:Can'tresolveallparametersfor[objectLocation]:(?).EXCEPTION:Can'tresolveallparametersfor[objectLocation]:(?).UnhandledPromiserejection:(SystemJS)Can'tresolveallparametersfor[objectLocation]:(?)

javascript - Angular2 提前 (AoT) 编译如何工作?

Angular2带有称为提前(AoT)的新功能。但是看了一番,还是不能真正理解。它是如何工作的?它将如何带来更好的性能?它与JIT有何不同?谢谢。 最佳答案 Angular在模块、指令和管道的View和装饰器中使用声明式绑定(bind),这些需要由浏览器中的JS解释以执行它们的预期目的。离线模板编译器用生成的静态代码替换声明式绑定(bind)和装饰器。这使得Angular2组件实例化和初始化更快,因为JS要做的工作更少。在将应用程序提供给客户端之前,组件的“编译”已经完成。如果您不使用其他在运行时需要它的功能,则可以省略platfo

javascript - 如何多重过滤对象数组?

这是我的演示代码://ImportsanddecoratorsuphereforAngular2exportclassProductsListComponent{products=[{name:"A",color:"Blue",size:50},{name:"B",color:"Blue",size:60},{name:"C",color:"Black",size:70}];filters={colors:["Blue","Black"],sizes:[70,50]};//Thisismyfirstapproachbutjustworksforthecolorsarrayinsidef

javascript - 遍历同一组件angular2的多个@ViewChild实例

我有一个Ionic2应用程序,它的ParentComponent调用ChildComponent@ViewChild方法来启动多个ChildComponent。其中一个ChildComponentsget在View中使用不同的参数实例化了两次,如下所示:在离线/在线设备状态更改后,我调用ChildComponent的方法来更新它返回的项目列表。@ViewChild(ChildComponent)childComponent:ChildComponent;ngOnInit():void{this.networkService.connectSubscription(()=>{this.c

javascript - 将 jQuery 与 angular 2+ 一起使用好吗

在搜索“showingbootsrapmodalinangular2”时,我遇到了以下答案:https://stackoverflow.com/a/38271918/1291122它只是将jQuery声明为:declarevarjQuery:any;并使用它来显示/隐藏模态,如下所示:jQuery("#myModal").modal("hide");这是在Angular2中实现我所需要的最短方法(其他所有答案似乎使它相当复杂,相当于火箭科学!)虽然这是最短的方法,但这是推荐的方法吗?一般来说,将jQuery与angular2+一起使用是个好主意吗?编辑:我的问题不同于Howtousej

javascript - 第一次加载组件时 Angular 4 ngOnInit 不工作

我在Angular4中有一个组件和一个用于更改路由的模板这个组件被调用但不加载任何没有服务器调用的东西。如果我将ngOnInit()方法内容放入构造函数中,它就可以正常工作。似乎没有调用ngOnInit。自从过去2天以来,任何人都可以帮助我处理这个问题。这是我的路由配置。consttestRouting:ModuleWithProviders=RouterModule.forChild([{path:'createtest/:id',component:TestComponent,resolve:{test:TestResolver}},{path:'createtest',compo

javascript - 未捕获的 TypeError : a. customFilter 不是 ngAnimate 的函数

我正在开发AngularJS应用程序,我尝试添加AngularAnimate。AngularRoute没有造成任何问题,但AngularAnimate似乎与我的应用程序中的某些内容不兼容。我按以下顺序加载库:并在我的app.js中使用它们:varapp=angular.module('tictactoe',['ngRoute','ngAnimate']);我收到以下错误。JQuery和Angular(Vanilla+Route+Animate)已通过npm安装依赖版本: 最佳答案 使用Angular版本1.6.5或将angular-