AngularJs 简单示例

来源:互联网 发布:comway 无线串口软件 编辑:程序博客网 时间:2024/06/05 11:56

一、简介

Angularjs作为前端mvc框架,可以说是非常显眼,使用来来也比较简单。本文章只记录一个简单的demo,AngularJs的官网有很多使用的介绍,如果想学习AnjularJs请跳过此文章直接查看http://angularjs.org/ 或者  http://docs.angularjs.org/guide/


二、示例

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html xmlns:ng="http://angularjs.org" id="ng-app" ng-app="AngularApp"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>AngularJs</title><script type="text/javascript" src="js/angular.js"></script></head><body><div ng-controller="GreetingCtrl" style="min-width: 1000px">姓名:{{ name }}</div><script type="text/javascript">var AngularApp = angular.module('AngularApp', []);AngularApp.controller('GreetingCtrl', function($scope, $http,$timeout, $filter) {//初始化页面$http({method : 'GET',url : '/myapp/dataServlet',}).success(function(data, status, headers, config) {$scope.loadDataFun(data);}).error(function(data, status, headers, config) {//alert(status);$scope.name="未知";});$scope.loadDataFun = function(dataVo) {$scope.name = dataVo.name;}});</script></body></html>



0 0