我正在使用堆栈MEAN.io开发一个webapp,现在我已经有了HTML,CSS和AngularJS的前端部分,其中包含一些逻辑。但是现在我想在服务器端登录而且我不知道从哪里开始,因为例如AngularJS它有定义路由的文件,它将使用什么模板以及哪个控制器,但是Express / Node部分?
如何实施此新登录?我有点失落。
我想做一些"管理"注册用户可以添加收藏的个人资料。就像在屏幕右侧添加一个书签一样。但我想在服务器端这样做。
问题是我找不到在哪里写服务器端代码和这个与前端相同的文件的关系。
例如,当我在索引页面时,我想显示之前添加的收藏夹配置文件。并存储到MongoDB当然。
答案 0 :(得分:2)
您有两种方法可以使用常规表单发布数据或使用$ http angular ajax post。
常规表单类型向服务器发布数据
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/match_result"
android:orientation="horizontal"
android:padding="16dp"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="left">
<TextView
android:id="@+id/matchUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username"
android:layout_marginRight="10dp"/>
<TextView
android:id="@+id/matchSex"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sex"
android:layout_marginRight="10dp"/>
<TextView
android:id="@+id/matchAge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Age"
android:layout_marginRight="10dp"/>
<Button
android:id="@+id/matchSendRequest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send Request"
android:minHeight="5dp"
android:minWidth="0dp"
android:layout_marginLeft="80dp"/>
使用ajax angular $ http方法发布数据
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dialogListView"
android:layout_width="wrap_content"
android:layout_height="fill_parent">
</ListView>
服务器端
<form action="/" method="post">
<input type"email" name="email" />
<input type"password" name="password" />
<input type="submit" value="login" />
</form>