2017-06-21 24 views
0

我正在嘗試使用角度js ui路由器來路由我的頁面。使用ui-sref時不會自動生成href

下面是我寫的代碼:

<a ui-sref="transporterEditDetails({companyId: '{{d.companyId}}')" style="cursor: pointer">{{d.companyName}}</a> 

這裏的js代碼:

var routerApp = angular.module('routerApp', ['ui.router','ui.bootstrap','xeditable','google.places','angular-loading-bar','ui.select','angularUtils.directives.dirPagination','notificationsTruckway','ui.tinymce']) 
routerApp.config(function($stateProvider, $urlRouterProvider,cfpLoadingBarProvider) { 
$stateProvider 
     .state('transporterEditDetails', { 
     url: '/transporterEditDetails/:companyId', 
     controller:'TransporterEditDetailsController', 
     templateUrl: 'Transporter-editDetails.html' 
    }) 
routerApp.controller('TransporterEditDetailsController', function($scope,$location,$http,usersFactory,$stateParams) { 
$scope.companyId = $stateParams.companyId; 
} 

我不知道什麼是錯在我的代碼,我無法獲得應該自動生成的href屬性。

回答

1

你嘗試不帶引號和括號

<a ui-sref="transporterEditDetails({companyId: d.companyId})" style="cursor: pointer">{{d.companyName}}</a> 
+0

我看到了,我將刪除引號和括號,並檢查它的工作。 – Harish

+0

非常感謝你的工作:) :) – Harish

+0

這是一個愚蠢的錯誤: – Harish

1

你並不需要使用{{}}(插值)內ui-sref。還刪除'(包裹單引號)

ui-sref="transporterEditDetails({companyId: d.companyId })" 
+0

我會試試看。 – Harish