我是MEAN堆栈的新手,我正在尝试创建一个基本的单页应用程序.
我正在尝试连接到mongodb,然后列出控制器中某个集合中的值.
但是,当我寻找答案时,我遇到了使用AngularJs和MongoDB/Mongoose的答案
如果你不能在angular和mongo之间使用它,那么让我感到困惑的是下面的代码是什么意思?或者是否有其他临时步骤使用它?
var mongoose = require('mongoose');
var db = mongoose.createConnection('mongodb://localhost:3000/database');
var orderSchema = new mongoose.Schema({
routeFrom : String,
routeTo : String,
leaving: String
});
var Order = db.model('Order', orderSchema);
module.exports = Order;
Run Code Online (Sandbox Code Playgroud)
编辑:我试图使用它的情况是这样的:
Geek.html
<div class="jumbotron text-center">
<h1>Geek City</h1>
<p>{{tagline}}</p>
<ul>
<li ng-repeat="value in dataValues">
{{value.name}}
</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
GeekController
angular.module('GeekCtrl', []).controller('GeekController', function($scope) {
$scope.tagline = 'The square root of life is pi!';
$scope.dataValues = function(){
var mongo = require('../config/db.js');
var collectionValues = mongo.myCollection.find();
return collectionValues; …Run Code Online (Sandbox Code Playgroud) public class A{
public static int x = 1;
public int m(A a, B b){
return a.m(b, b) + x;
}
}
public class B extends A {
public int m(A a1, B a2){
if(a1 == a2)
return x;
return super.m(a1,a2);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我过去考试的一个问题.
public class Main{
public static void main(String[] args){
B b1 = new B(){int m(A a, A b){ return 10; }};
System.out.println(b1.m(b1, b1));
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,以下输出是什么.我在答案1中是对的.但我没有完全理解为什么.
由于B对象的内部类是(A,A).我是否正确认为它不能覆盖超级方法m,因为它是(A,B)?如果交换了两个方法的参数,它是否能够覆盖?
既然它既不能覆盖也不能超载,它什么也不做,只是在B类中使用方法m?
对象的内部类是否仅适用于自身?它就像一个异类吗?
为所有问题道歉.
提前致谢.
编辑:
从我到目前为止的理解,因为静态类型设置为B,所以类型B无法看到anon类.如果将其设置为公开,则可以看到它,但仍然不会使用它.
这使我对另一个问题感到困惑.
public class A{ …Run Code Online (Sandbox Code Playgroud)