小编Sha*_*han的帖子

AngularJs:将参数传递给ng-click in指令

我有一个指令,我在其中添加一个按钮和按钮上的ng单击.我的指令代码是

AppDirectives.directive(
                'feed',
                function() {
                    return {
                        restrict : 'AE',
                        scope : {
                            feedMsg : '@feedText',
                            feedUser : '@feedUser',
                            feedTimestamp : '@feedTimestamp',
                            feedLike : '@feedLike',
                            feedDislike : '@feedDislike',
                            likeClick: '&',
                            dislikeClick :'&',
                            feedUid : '@feedUid'
                        },
                        template : '<div class="media">'+
                                        '<a class="pull-left" href="#"><img class="media-object" src="resources/images/holder.png" style="height:64px; width:64px;" alt="img"></a>'+
                                        '<div class="media-body">'+
                                            '<h4 class="media-heading">{{feedUser}}</h4>'+
                                            '<h5>{{feedMsg}}</h5>'+
                                            '<p> <a ng-click="likeClick(feedLike)">Like</a> {{feedLike}} <a ng-click="dislikeClick(feedUid)">Dislike</a> {{feedLike}} {{ feedTimestamp | date:medium }} </p>'+
                                        '</div>'+
                                    '</div>',
                        replace : true,

                    };
                });
Run Code Online (Sandbox Code Playgroud)

我的HTML代码是

<feed feed-uid={{feed.uid}} feed-text={{feed.feedText}} feed-user={{feed.userUid}} feed-timestamp={{feed.time}} feed-like={{feed.like}} …
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-directive angularjs-scope

4
推荐指数
1
解决办法
5208
查看次数

Angularjs:如何使用对象的键来检索另一个json对象的值

我有一个json对象数组

$scope.arrary = [{"a":"value"},{"b":"value2"},{"c":"value3"}];

$scope.secondObje = {"a":"this is updated value","b":"this is new value"}
Run Code Online (Sandbox Code Playgroud)

我可以使用迭代遍历'数组'

<div ng-repeat="(key,value) in array">
Run Code Online (Sandbox Code Playgroud)

现在我如何使用键访问第二个对象的值

我想要一些类似的东西{{secondObje.key}},我怎么能在角度上做到这一点.

所以我得到"this is updated value""this is new value"打印.

请帮我.

angularjs angularjs-directive angularjs-ng-repeat

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

读取具有锈蚀的.dfb文件会引发无效字符错误

我刚接触锈并创建POC来将dbf文件转换为csv。我正在.dbf使用rust库dbase读取文件。

问题是,当我.dbf使用dbfview创建样本文件时,代码工作正常。但是,当我使用.dbf 实时使用的文件时。我收到以下错误。

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidFieldType('M')', src/libcore/result.rs:999:5
Run Code Online (Sandbox Code Playgroud)

这是我从给定链接使用的代码。

use dbase::FieldValue;
let records = dbase::read("tests/data/line.dbf").unwrap();
for record in records {
    for (name, value) in record {
        println!("{} -> {:?}", name, value);
        match value {
            FieldValue::Character(string) => println!("Got string: {}", string),
            FieldValue::Numeric(value) => println!("Got numeric value of  {}", value),
            _ => {}
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我认为这些^M显示的字符由附加windows。我该怎么办以解决此错误并成功读取文件。任何帮助都感激不尽。

dbf dbase rust

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

编写新的角度服务返回错误错误:未知的提供者

我正在尝试按照本教程编写一个简单的服务.添加新服务的代码是:

'use strict';
var projectModule = angular.module('project',[]);
projectModule.factory('Team', function() {  
    return {
        thing : {
            x : 100
        }
    };
});
Run Code Online (Sandbox Code Playgroud)

我的控制器代码是:

var Controllers = angular.module('fixedTeam',[]);
Controllers.controller('controller', function ($scope,$http,$location,Team) {
    $scope.getFixedTeam = function(){
        console.debug(Team.thing);
    }
});
Run Code Online (Sandbox Code Playgroud)

当我加载视图时,我收到以下错误:

Error: Unknown provider: TeamProvider <- Team
createInjector/providerInjector<@http://localhost:8080/tm-webapp/resources/lib/angular.js:2734
getService@http://localhost:8080/tm-webapp/resources/lib/angular.js:2862
createInjector/instanceCache.$injector<@http://localhost:8080/tm-webapp/resources/lib/angular.js:2739
getService@http://localhost:8080/tm-webapp/resources/lib/angular.js:2862
invoke@http://localhost:8080/tm-webapp/resources/lib/angular.js:2880
instantiate@http://localhost:8080/tm-webapp/resources/lib/angular.js:2914
@http://localhost:8080/tm-webapp/resources/lib/angular.js:4805
update@http://localhost:8080/tm-webapp/resources/lib/angular.js:14198
Scope.prototype.$broadcast@http://localhost:8080/tm-webapp/resources/lib/angular.js:8307
updateRoute/<@http://localhost:8080/tm-webapp/resources/lib/angular.js:7463
qFactory/defer/deferred.promise.then/wrappedCallback@http://localhost:8080/tm-webapp/resources/lib/angular.js:6846
qFactory/defer/deferred.promise.then/wrappedCallback@http://localhost:8080/tm-webapp/resources/lib/angular.js:6846
qFactory/ref/<.then/<@http://localhost:8080/tm-webapp/resources/lib/angular.js:6883
Scope.prototype.$eval@http://localhost:8080/tm-webapp/resources/lib/angular.js:8057 
Scope.prototype.$digest@http://localhost:8080/tm-webapp/resources/lib/angular.js:7922 
Scope.prototype.$apply@http://localhost:8080/tm-webapp/resources/lib/angular.js:8143 
done@http://localhost:8080/tm-webapp/resources/lib/angular.js:9170 
completeRequest@http://localhost:8080/tm-webapp/resources/lib/angular.js:9333 
createHttpBackend/</xhr.onreadystatechange@http://localhost:8080/tm-webapp/resources/lib/angular.js:9304 
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

angularjs

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