我已从v 1.0.8升级到Angular 1.2.9以帮助我的应用程序的性能.
我已经介绍了提高速度的轨道.
我曾经拥有的
<div class="result row"
data-ng-repeat="result in (filteredItems =
(results |
filter: filterPrice |
filter: filterCategories |
filter: filterTypes |
filter: filterAirConditioning |
filter: filterTransmission |
filter: filterFourByFour |
filter: filterFuelType |
filter: filterNumberOfDoors |
filter: filterOnAirport |
filter: filterFuelPolicy |
filter: filterUnlimitedMileage |
filter: filterFreeCancellation |
filter: filterTheftProtection |
filter: filterCDW |
filter: filterTaxesIncluded |
filter: filterProviders ) ) |
orderBy: [orderByOptions, orderByPriceLowToHigh, orderByPriority] |
limitTo: pageSize">
Run Code Online (Sandbox Code Playgroud)
我现在有什么
<div class="result row"
data-ng-repeat="result in results |
filter: …Run Code Online (Sandbox Code Playgroud) 当前版本的Material Angular DatePicker发生了一些非常奇怪的事情,在我将它从A5更新到A6之后,它开始在前一天解析我的日期,示例在这里:https://stackblitz.com/edit/angular6-日期选择器的解析,错误的日期
我正在使用原始文档示例,对我自己的语言稍有改变语言,并将自定义日期值应用于ngModel,以便它可以解析.
但你可以在这里查看代码:
import {Component} from '@angular/core';
import {MAT_MOMENT_DATE_FORMATS, MomentDateAdapter} from '@angular/material-moment-adapter';
import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/core';
@Component({
selector: 'datepicker-locale-example',
templateUrl: 'datepicker-locale-example.html',
styleUrls: ['datepicker-locale-example.css'],
providers: [
{provide: MAT_DATE_LOCALE, useValue: 'pt'}, //my change from the original documentation example
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
{provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS},
],
})
export class DatepickerLocaleExample {
constructor(private adapter: DateAdapter<any>) {}
private someDate = '2018-01-31'; //my change from the original documentation example
french() {
this.adapter.setLocale('fr');
}
}
Run Code Online (Sandbox Code Playgroud)
HTML: …
我有一个来自服务器的简单字符串数组:
[{"things":["me", "my"]}]
Run Code Online (Sandbox Code Playgroud)
在我的页面中,要显示我拥有的数组:
{{things}}
Run Code Online (Sandbox Code Playgroud)
它打印:
["me", "my"]
Run Code Online (Sandbox Code Playgroud)
如何控制打印,例如,如果我想删除括号和引号?
我有以下代码:
angular
.module('myApp')
.directive('layout', function () {
return {
restrict: 'E',
template: '<div ng-include="layoutCtrl.pageLayout"></div>',
controller: 'LayoutController',
controllerAs: 'layoutCtrl',
bindToController: true,
scope: {
pageLayout: '=',
pageConfiguration: '=',
isPreview: '='
}
};
});
angular
.module('myApp')
.controller('LayoutController', LayoutController);
function LayoutController($scope, LayoutDTO, LayoutPreviewDTO) {
var self = this;
self.layoutDTO = LayoutDTO;
self.layoutPreviewDTO = LayoutPreviewDTO;
var test = $scope;
if(self.isPreview)
self.layoutModel = new self.layoutPreviewDTO(self.pageConfiguration);
else
self.layoutModel = new self.layoutDTO(self.pageConfiguration);
}
<div>
<layout page-layout="ctrl.layoutTemplateUrl" page-configuration="ctrl.pageConfiguration" is-preview="false"></layout>
</div>
Run Code Online (Sandbox Code Playgroud)
在角度1.5.3版本中,这按预期工作,我的控制器中的变量带有值.现在,自从我升级到1.6.x后,self.pageConfiguration现在未定义.
除角度版本外,没有任何改变.
如何处理传递给控制器中指令的值?
angularjs angular-directive angular-controller angularjs-1.6
安装角度材料后,我在角度4项目中出现此错误
模块'AppModule'声明的意外模块'MdAutocompleteModule'.请添加@ Pipe/@ Directive/@ Component注释.
这是我的app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { environment } from './../environments/environment';
import { AngularFireModule } from 'angularfire2';
// New imports to update based on AngularFire2 version 4
import { AngularFireDatabaseModule } from 'angularfire2/database';
import { AngularFireAuthModule } from 'angularfire2/auth';
// import material
import …Run Code Online (Sandbox Code Playgroud) 因此,我试图在Angular 4 Angular CLI上运行“ ng test”。我遇到了许多问题,例如如果测试失败,UI不会加载任何有用的消息,但是幸运的是控制台可以正常工作。无论如何,发生此错误是说我没有在规范中给MatSnackBar一个提供者,但是当我这样做时,我得到了另一个错误。
Chrome 66.0.3359 (Linux 0.0.0) BranchNameCellComponent should create FAILED
Error: No provider for MatSnackBar!
Run Code Online (Sandbox Code Playgroud)
当我包含MatSnackBar作为导入时出错
Chrome 66.0.3359 (Linux 0.0.0) BranchNameCellComponent should create FAILED
Failed: Unexpected value 'MatSnackBar' imported by the module 'DynamicTestModule'. Please add a @NgModule annotation.
Run Code Online (Sandbox Code Playgroud)
在我的组件代码中,我要导入MatSnackBar并在构造函数中调用它。工作正常。
import { MatSnackBar } from '@angular/material';
....
constructor(private httpClient: HttpClient, private fb: FormBuilder, public snackBar: MatSnackBar) { }
Run Code Online (Sandbox Code Playgroud)
但是在规范中,我没有用。
import { MatSnackBar } from '@angular/material';
....
describe('BranchNameCellComponent', () => {
let component: BranchNameCellComponent;
let fixture: ComponentFixture<BranchNameCellComponent>;
beforeEach(async(() …Run Code Online (Sandbox Code Playgroud) 我正在尝试这样做,但看起来只能将其更改为主要或警告.
我正在尝试在Angular2中集成ng2-material
Uncaught SyntaxError:angular2-polyfills.js:138 Uncaught SyntaxError:意外的令牌<评估 http:// localhost:3000/ng2-material/all
import {MATERIAL_PROVIDERS, MATERIAL_DIRECTIVES} from 'ng2-material/all';
@Component({
template: `<md-content>
<button md-raised-button class="md-raised md-primary">Primary</button>
</md-content>`,
styles: [style],
providers:[ContactService, MATERIAL_PROVIDERS]
directives:[MATERIAL_DIRECTIVES]
})
export class contact {
constructor(){}
}
Run Code Online (Sandbox Code Playgroud) 我试图使用*ngFor但迭代迭代对象的属性in.当我尝试这样做
@Controller({
selector: 'sample-controller',
template: `
<ul>
<li *ngFor="let i in obj">
<b>{{i}}</b>: {{obj[i]}}
</li>
</ul>`
})
class SampleController {
obj = {a: 1, b: 2}
}
Run Code Online (Sandbox Code Playgroud)
我收到错误消息:
无法绑定到'ngForIn',因为它不是'li'的已知属性.
我已经包含FormsModule并BrowserModule在imports一节@NgModule此组件.
是否有可能使用ngForIn上li,如果没有有一个惯用的方法吗?
我将重点放在开发工具中的组件元素上,可以执行以下操作:
ng.probe($0)
Run Code Online (Sandbox Code Playgroud)
获取特殊对象" DebugElement ".现在我们可以得到它的注射器:
ng.probe($0).injector
Run Code Online (Sandbox Code Playgroud)
现在我想得到一个在这个组件上定义的依赖.依赖性被定义为类,所以我应该这样做:
ng.probe($0).injector.get(MyService)
Run Code Online (Sandbox Code Playgroud)
但!服务器未在控制台范围中定义.如果我把它变成一个字符串:
ng.probe($0).injector.get('MyService')
Run Code Online (Sandbox Code Playgroud)
显然它也行不通.
我正在尝试在ReflectiveInjector.get上进行逆向工程,但现在没有运气.有任何想法吗?
angular ×7
angularjs ×3
typescript ×2
angular-cli ×1
angular-di ×1
arrays ×1
datepicker ×1
filter ×1
ngfor ×1
testing ×1