我有下面的鏈接如何在URL傳遞角JS的值作爲參數
<a href="entity-details.html?id='{{ x.community_id }}&community_society_id={{x.community_society_id}}">View</a>
欲x.community_id和x.community_society_id值傳遞給控制器再後來我獲取數據。
var app = angular.module('EntityApp', []);
app.controller('EntityAppCntroller', function($scope, $http, $location) {
var myParamtr = location.search.split('id=')[1] ? location.search.split('id=')[1] : 'myDefaultValue';
alert(myParamtr);
$http.get('apartment/community/details/list/'+ myParam).then(function(response) {
$scope.myData = response.data.list;
});
});
,而不是'href',使用'NG-href' – tanmay
好,但我認爲,在錨標記語法是錯誤的,我認爲u能解決這個問題? –
如果它是ng模型的值,那麼你不必將它傳遞給控制器,範圍變量將在你的控制器中可用 – CrazyMac