Angularjs 前端和后端连接-mvc模式中的节点和角度
如何使用angularjs mvc在滚动条中显示以下json 使用nodejs从api localhost:port/details获取的myjson:Angularjs 前端和后端连接-mvc模式中的节点和角度,angularjs,node.js,angular-resource,Angularjs,Node.js,Angular Resource,如何使用angularjs mvc在滚动条中显示以下json 使用nodejs从api localhost:port/details获取的myjson: [ { "id": 4, "notes": "sdas 123", "invoice": "232", "objectType": "Customer", "objectId": 5, "dateCreated": "2015-09-29T22:54:06.000Z", "dateMo
[
{
"id": 4,
"notes": "sdas 123",
"invoice": "232",
"objectType": "Customer",
"objectId": 5,
"dateCreated": "2015-09-29T22:54:06.000Z",
"dateModified": "2015-10-08T23:01:16.000Z"
},
{
"id": 10,
"notes": "sample Test",
"invoice": "123",
"objectType": "Customer",
"objectId": 5,
"dateCreated": "2015-09-30T06:38:52.000Z",
"dateModified": "2015-09-30T01:20:38.000Z"
}
]
有人帮忙吗。。?
是的,我已经这样开始并尝试了:在我的控制器中 我的配置为:
angular.module('customerdetails).config(['$stateProvider',
function($stateProvider) {
$stateProvider.
state('listCust', {
url: '/details',
templateUrl: "/customerdetails/views/listcustomer.client.view.html'
});
}
])
我的服务:
angular.module('customer').factory('Customer',function($resource)
{
return $resource('/details');
});
我的控制器:
angular.module('customerdetails').controller('CustomerController', ['$scope', '$rootScope', '$state', '$stateParams', '$location', 'Authentication', 'Customer', 'InvoiceRefund', '$filter',
function ($scope, $rootScope, $state, $http, $stateParams, $location, Authentication, Customer, $filter) {
var cus = Customer.query(function() {
console.log(cus);
});
要显示JSON数据,您可以使用以下语法:{variable | JSON}}在模板中,但为此您需要分配$scope.variable=YOUR_JSON;在你的控制器代码中你能提供你的html页面和angularjs的代码吗?谢谢Shershen,但这里我需要从api/details中获取json数据,我是使用nodejs创建的。因为我对angular是新手,我需要知道如何在服务中使用$resource获取api,并在angular的控制器中定义。然后,您应该从一个教程开始,例如-,这是如何编写超级简单控制器-是的,我已经开始并尝试这样做:在我的控制器angular.module'customerdetails'。controller'CustomerController',[“$scope”、“$rootScope”、“$state”、“$stateparms”、“$location”、“Authentication”、“Customer”、“invoicereturn”、“$filter”、函数$scope、$rootScope、$state、$http、$stateparms、$location、Authentication、Customer、$filter{var customers=Customer.queryfunction{console.logcustomers;};];我的服务是:angular.module'customer'。factory'customer',function$resource{return$resource'/details';};不,在这里发布不可读的代码块将不起作用。请完全更新您的问题-使用您收到的数据、控制代码和服务代码等,然后每个人都可以查看