我有两个服务:LoginService和UserService.我试图将UserService注入LoginService,该应用程序将无法运行.
在控制台中,我有错误:
错误:无法解析UserService的所有参数:([object Object],?).在SyntaxError.ZoneAwareError(http:// localhost:4200/polyfills.bundle.js:7156:33)处于SyntaxError.BaseError [作为构造函数]
这是我的LoginService:
import {UserService} from '../services/user.service';
@Injectable()
export class LoginService {
constructor(public _http: Http,public us:UserService) {
}
Run Code Online (Sandbox Code Playgroud)
和UserService:
@Injectable()
export class UserService {
constructor(private _http: Http , public _ls: LoginService) {
}
Run Code Online (Sandbox Code Playgroud)
角度模块:
import {LoginService} from './services/login.service';
import {UserService} from './services/user.service';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
],
exports: [BrowserModule, SlimLoadingBarModule],
providers: [UserService, LoginService, appRoutingProviders],
bootstrap: [AppComponent]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud) 我已经完成了对我的应用程序的编码,并尝试将其构建为生产模式,并且在测试了该应用程序之后,我看到图像未在应用程序中显示为徽标...但是在开发模式下还可以。这是我的项目的树:
是否需要将webpack添加到我的项目中以解决此问题?
我还想问一下webpack的功能,因为我的项目不包括webpack,我发现有必要将它用作我的应用程序。
我正在尝试使用typescript 2.0.3创建一个类但我有一些问题,我不知道为什么.
这是我的代码
import { Component, OnInit } from '@angular/core';
import {Car} from '../interfaces/car';
class PrimeCar implements Car
{
constructor(public vin, public year, public brand, public color) {}
}
@Component({
selector: 'rb-test',
templateUrl: './test.component.html',
styleUrls: ['./test.component.css']
})
export class TestComponent implements OnInit {
displayDialog: boolean;
car: Car = new PrimeCar(null, null, null , null);
selectedCar: Car;
newCar: boolean;
cars: Car[];
constructor() { }
ngOnInit() {
this.cars = [ {vin: '111', year: '5554' , brand: '5646' , color: '6466' },
{vin: …Run Code Online (Sandbox Code Playgroud) 我知道我们可以编辑Material UI的主题, 但我正在考虑让它变得动态,在我们可以设置 SASS 变量的地方,它会自动更新 Material UI 主题。
我使用 sass 来设计我的页面,这里是我使用的变量示例:
$primary-color: #1E79C7;
$secondary-color: #E5681A;
Run Code Online (Sandbox Code Playgroud)
目前对我来说,我对材质 ui 按钮执行以下操作,因为我希望我的设计尽可能多地放在一个地方
.app-button-blue {
background-color: $primary-color !important;
margin: 5px;
}
.app-button-gray {
background: transparent !important;
box-shadow: none !important;
}
.app-button-white {
background: transparent !important;
box-shadow: none !important;
border: $primary-color solid 1px !important;
}
Run Code Online (Sandbox Code Playgroud)
有没有办法让我使用这个 SASS 变量来覆盖材质 ui 的主题——比如设置主色和辅助色?
在我的服务中,我想等到本地变量baseurl未初始化,然后再发出另一个http请求.
以下是我的服务代码:
@Injectable()
export class CoursesService {
baseUrl;
constructor(private http: Http) {
if(this.baseUrl != undefined){
this.getJSON().subscribe(data =>
this.baseUrl=data,
error => console.log(error)
);
}
}
public getJSON(): Observable<any> {
return this.http.get("assets/apiDetails.json")
.map((res:any) => res.json());
}
getCourses(){
return this.http.get(this.baseUrl+"/courses")
.map((res:any) => res.json());
}
}
Run Code Online (Sandbox Code Playgroud)
正如你所看到的getCourses方法使用baseUrl变量,所以当我调用getCourses方法时,我想等到 baseUrl没有初始化.
我试过使用ngOnInit但它不会在Injectable类型类中调用.
angular ×4
javascript ×2
angular-cli ×1
image ×1
inject ×1
material-ui ×1
reactjs ×1
rxjs ×1
sass ×1
service ×1
themes ×1
typescript ×1