0
下面是粗糙的代碼不完全語法角JS,控制器變量不能夠讀取指令
/JS文件 (函數(){
var app = angular.module('ngABC', []);
var nodes = [];
Here is the controller to get all node fron server using http
app.controller('nodesController', function($scope,$http){
$http({
url: $url,
method: "POST",
data: postData,
headers : {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(response) {
$Scope.nodes = response;
});
});
//響應是象 [{」基本「:{」node_id「:」8「,」title「:」NEWS主題「,」別名「:」新聞主題「,」created_by「:12345」}}] ........
This is the directive to get node owner's user name.
app.directive('username', function() {
restrict = 'E';
templateUrl = function(ent,attr){
return url+attr.userid;
}
});
// ========這是PHP文件,顯示的所有節點上,
<div ng-repeat="x in nodes">
{{ x.basic.node_id}} // printing as "8"
{{ x.basic.title}} // printing "NEWS TOPIC"
<username userid="{{x.basic.created_by}}"></username>
//Here need's owner Name. SO i am using Directive ANd
by templateUrl and going to server with userid to get his NAME
Directive should take user_id as "12345" but taking as "{{x.basic.created_by}}"
</div>
我想templateUrl像 「URL/GET_NAME/12345」, 但它正在像「URL/GET_NAME/{{x.basic.created_by}}」
你的鱈魚e是一個混亂,無意義的混亂。請創建一個[MCVE](http://stackoverflow.com/help/mcve),其中顯示了它使用的代碼和數據。 – 2014-09-12 12:04:01
@DarkFalcon現在清楚了嗎? – aparna 2014-09-12 12:20:10
是的,除了確切的問題,更清晰。你無法讀取什麼變量? – 2014-09-12 12:22:59