【发布时间】:2016-07-19 17:52:47
【问题描述】:
我正在尝试使用这个 AngularJS 材料芯片。 (联系芯片 - 具有自动完成功能) https://material.angularjs.org/latest/demo/chips
而且它的结构与我习惯的不同。我想适应使用 $http 从我的 mongodb 获取联系人,例如:
$http.get("/contacts").success(function(response) {
contacts = response;
});
但在他们的 Angular Material 代码示例中是这样的:
angular.module('MyApp',['ngMaterial', 'ngMessages', 'material.svgAssetsCache'])
.controller('ContactChipDemoCtrl', DemoCtrl);
function DemoCtrl ($q, $timeout) {
...
function loadContacts() {
var contacts = [
'Marina Augustine',
'Oddr Sarno',
'Nick Giannopoulos',
'Narayana Garner',
'Anita Gros',
'Megan Smith',
'Tsvetko Metzger',
'Hector Simek',
'Some-guy withalongalastaname'
];
}
...
如何使用 $http 作为 DemoCtrl 函数的参数?从 db 中获取联系人
【问题讨论】:
-
密码笔链接在哪里?
-
你只是在问依赖注入如何与 Angular 一起工作?我建议你看看文档docs.angularjs.org/guide/di
-
@Sajeetharan 点击上面的链接并转到 CONTACT CHIP,有一个 codepen 图标
标签: javascript angularjs mongodb