0
我正在使用ResourceMock.js來僞造數據並返回一些custome產品數據。 當我嘗試獲得產品清單並點擊網址/產品時,Thing的工作正常ResourceMock.js未解析正確的URL
但是對於特定產品,我想通過產品ID並且URL將類似於/ product/edit?productId。
我想獲得使用一些正則表達式的東西,但它不按預期工作的功能。
登錄控制檯的錯誤是意外的請求:GET/API /產品的productId = 4
//working fine for getting list of all products. :)
var producturl = "/api/products";
$httpBackend.whenGET(producturl).respond(products);
//when try to get specific item things goes wrong. :(
var editRegex = new RegExp(producturl + "/[A-Za-z0-9]", '');
alert(editRegex);
$httpBackend.whenGET(editRegex).respond(function(method, url, data) {
//do some stuff and return
});