小编Jef*_*aal的帖子

你似乎不依赖于"@ angular/core".这是一个错误

我想用角度cli创建一个角度2 App

我写的是cmd:

npm install angular-cli -g

然后:

ng firstngapp

但是当我写下npm start时它会显示错误! 错误图像

文件图片

我不明白这个问题

npm angular-cli angular

133
推荐指数
8
解决办法
16万
查看次数

Angular 2 ngfor first,last,index loop

我试图将此示例中的第一个设置为默认值:plunkr

收到以下错误:

Unhandled Promise rejection: Template parse errors:
TypeError: Cannot read property 'toUpperCase' of undefined ("dButtonToggleGroup">
                                                            <md-button-toggle [ERROR ->]*ngFor="let indicador of indicadores; #first = first" value="indicador.id" [checked]="first">
      "): ng:///AppModule/HomeComponent.html@35:78
Parser Error: Unexpected token #, expected identifier, keyword, or string at column 31 in [let indicador of indicadores; #first = first] in ng:///AppModule/HomeComponent.html@35:78 ("       <md-button-toggle *ngFor="let indicador of indicadores; #first = first" value="indicador.id" [ERROR ->][checked]="first">
                                                                <span>{{ indicado"): ng:///AppModule/HomeComponent.html@35:153
Run Code Online (Sandbox Code Playgroud)

怎么了??

angular-material angular

59
推荐指数
3
解决办法
8万
查看次数

angularjs和angular cli有什么区别?

角度有两种可用的东西:1.angular cli 2.angularjs

请简要描述一下.谢谢

angularjs angular-cli

14
推荐指数
3
解决办法
2万
查看次数

AngularJS是否具有在div中对属性进行别名的语法?

这是一个奇怪的问题,但这里的想法是:

假设我有一个复杂的JSON对象从HTTP调用返回并附加到$scope.像这样的东西:

$scope.obj = {
    user: {
        id: 10,
        name: { first: 'Joe', last: 'Smith' },
        contact: {
            home: {
                street: '101 First St.',
                city: 'Myville',
                state: 'Jokelahoma',
                zip: '98765'
            },
            email: 'joeshmoe@gmail.com',
            phone: '+12345678901'
        }
    },
    purchase_hist: [
        { item_id: 11004, date: 'Thu, 06 Aug 2015 13:51:17 GMT' },
        { item_id: 97020, date: 'Fri, 31 Jul 2015 18:57:57 GMT' }
    ]
}
Run Code Online (Sandbox Code Playgroud)

现在,如果我想在AngularJS partial中显示购买历史的概述,我可以这样做:

<table>
    <tr ng-repeat="p in obj.purchase_hist">
        <td>{{p.item_id}}</td>
        <td>{{p.date}}</td>
    </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

关于这种格式真正方便的事情(尽管这里的道具并不是很明显),所描述的购买是别名的p.我不必这样做obj.purchase_hist[0].item_id …

javascript alias angularjs

10
推荐指数
3
解决办法
6826
查看次数

渐变背景颜色::选择

有没有办法为CSS添加渐变颜色::selection


如果我使用这样的东西:

::selection {
  background-image: -webkit-linear-gradient(left, #ee4037 0%, #eb297b 100%);
}
Run Code Online (Sandbox Code Playgroud)

这是行不通的.

css gradient selection css3

10
推荐指数
1
解决办法
1995
查看次数

AngularJS ng-bind需要显示变量+"string"

ng-bind在模板中创建了一个元素,它显示一个舍入一位小数的数字.如何%ng-bind逻辑中添加一个到它的末尾?

我的代码:

<span ng-bind="variable | number: 1" 
      class="animated" ng-show="variable" 
      ng-class="{'fadeIn':variable}"></span>
Run Code Online (Sandbox Code Playgroud)

结果(例如)4.5但我想要它4.5%.

问题是,我想在%它的末尾添加一个字符,但是如何?我宁愿不添加第二个跨度,具有完全相同的逻辑,仅适用于那个字符,并且ng-bind="variable + '%' | number: 1"不起作用.我还想避免在我的控制器/指令中使用额外的代码,因为我认为这更像是一个模板(我只需要使用它几次).

angularjs ng-bind

6
推荐指数
1
解决办法
1万
查看次数

如何排序,然后选择一个项目

我正在使用XSLT从Feed中获取数据.目前我使用这个代码块,它只是从feed中选择第一个项目.我稍微改了一下,所以它适用于这个示例XML.

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
  <html>
  <body>
  <xsl:apply-templates/> 
  </body>
  </html>
</xsl:template>

<xsl:template match="/">
  <xsl:value-of select="catalog/book/author"/>
</xsl:template>

</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

我想按价格对xml进行排序,然后选择与价格最高的书籍相关联的作者.我尝试了各种各样的东西,但我似乎无法弄明白.

目前的输出是"Gambardella,Matthew",但我需要它是"Galos,Mike".

xml sorting xslt

5
推荐指数
1
解决办法
355
查看次数

如何获取echarts百度中dataZoom更改事件的开始和结束值?

如何获取echarts百度中dataZoom更改事件中的start和的值?end

vue.js echarts

5
推荐指数
1
解决办法
2364
查看次数

带参数的角路由redirectTo

我有角度布线问题。在我的应用中,我有一些这样的路线:

[{
     path: 'myroutes/:id',
     component: BarComponent
 }, {
     path: 'myroutes/:id/:value',
     component: FooComponent
 }]
Run Code Online (Sandbox Code Playgroud)

我想更改此路由,但是必须将旧路由重定向到新路由。所以我这样改变了我的代码:

[{
    path: 'myroutes/:id/:value',
    redirectTo: 'myroute/:id/:value'
}, {
    path: 'myroutes/:id',
    component: BarComponent
}, {
    path: 'myroute/:id/:value',
    component: FooComponent
}]
Run Code Online (Sandbox Code Playgroud)

通过此路由,我得到了NavigationError:

无法重定向到'/ myroute /:id /:value'。找不到':id'。

更改代码以在redirectTo路由中使用固定参数可以解决错误,但是参数必须是动态的。

路线是使用导入的RouterModule.forRoot()

希望这是足够的信息,否则请随时要求更多。;)

谢谢你的帮助!:)

angular angular-router

5
推荐指数
2
解决办法
4148
查看次数

如何将 http 请求响应映射到我在 TypeScript 中定义的对象

我开始了解 Angular、TypeScript 和 RxJS。我有一个返回 JSON 的 http 请求。在这个 JSON 中有我需要构建我定义的对象的数据。假设我的对象是这样的:

export class RegularUser {
    constructor(
        public id: number,
        public firstName: string,
        public lastName: string,
        public token: string
    ) {}
}
Run Code Online (Sandbox Code Playgroud)

现在,我向某个 API 发送请求,它以这种格式返回数据:

{
    success: boolean,
    uid: number,
    first_name: string,
    last_name: string,
    cid: number,
    rights: number[]
    token: string
}
Run Code Online (Sandbox Code Playgroud)

我有 HttpClient 服务,所以我想我会这样做:

this.httpClient.get(
    'http://api.example.com/api/get_user'
).pipe(
    tap((receivedData: Response) => console.log(receivedData)),
    map((receivedData: Response) => {
        return new RegularUser(
            receivedData.uid, 
            receivedData.first_name, 
            receivedData.last_name, 
            receivedData.token);
    })
);
Run Code Online (Sandbox Code Playgroud)

但是对于 TypeScript,receivedData对象没有上面列出的参数。我是否必须为 API 响应创建一个接口,然后将其映射到我的RegularUser对象?

interface rxjs typescript angular

5
推荐指数
1
解决办法
2万
查看次数