【问题标题】:how to match variable string to json response object如何将变量字符串与json响应对象匹配
【发布时间】:2016-09-13 15:09:49
【问题描述】:

如何将var apiMatch = '/api/Customer'string变量匹配到来自API调用的JSON响应对象

JSON 对象如下图所示

我认为这样做很简单

if(data.paths == apiMatch ) {
  // Do something here when its matched
  console.log('its matched');
} else {
   console.log('Nothing');
}

【问题讨论】:

    标签: angularjs json angular


    【解决方案1】:

    你的问题不清楚。您是否尝试从地址栏中获取 URL?

    如果是这样,你可以试试$location

    【讨论】:

    • 不尝试获取 URL,我尝试将 apiPath="" 的 url 参数值(即 /api/Customer)与上图中显示的 JSON 响应对象匹配。
    • 改写我的问题。
    猜你喜欢
    • 1970-01-01
    • 2011-01-16
    • 1970-01-01
    • 2017-01-17
    • 2014-06-20
    • 2020-04-06
    • 1970-01-01
    • 2017-04-13
    • 2019-08-19
    相关资源
    最近更新 更多