AngularJS初探

angularJS不依赖于jquery,只要引入它的js就可以使用了。此教程适用于使用angularJS做增删改查不知如何入手的新手。

angularJS v1.4.6下载地址:http://download.csdn.net/detail/qq_33556185/9617586

接下来开始angularJS之旅:

ng-app初始化angularJS应用

ng-controller是控制器

ng-repeat是迭代器,类似于Java或者C#里的foreach

{{对象.属性}} 双大花括号是angular的表达式,用来输出数据

ng-if是条件判断

	<div class="mt-20" ng-app="myApp" ng-controller="customersCtrl">
		<table class="table table-border table-bordered table-bg table-hover table-sort">
			<thead>
				<tr class="text-c">
					<th>名称</th>
					<th>key</th>
					<th>流程id</th>
					<th>流程文件</th>
					<th>流程图</th>
					<th>状态</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<tr class="text-c" ng-repeat="d in records">
					<td>{{ d.name}}</td>
					<td>{{ d.key }}</td>
					<td>{{ d.id }}</td>
					<td>{{ d.resourceName }}</td>
					<td>{{ d.diagramResourceName }}</td>
					<td>{{ d.state }}</td>
					<td>
					  <p ng-if='d.state=="运行中"'>
					   <input type="button" value="挂起" ng-click="operation(d.id,'suspend')" href="javascript:;">
					  </p>
					  <p ng-if='d.state=="已挂起"'>
					   <input type="button" value="激活" ng-click="operation(d.id,'fire')"  href="javascript:;">
					  </p>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
$http是angular的核心服务,用来发送http请求的(和jquery里的ajax用法功能一样),此服务发送参数会以json的形式发送,因此,springMVC里如果不设置接收参数为json,会接收不到参数。 使用@RequestBody注解到参数上即可。
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
    //查询
   $http.post("/activiti/user_process/findDefinitionProc")
    .success(function (response) {
    $scope.records = response.data;});
    
    //提交表单(增、删、改)
    $scope.operation = function (procId,type) {
       $http.post("/activiti/user_process/activiteOrSuspend",{id:procId,operation:type})
          .success(function (response) {
          window.location.reload();
       });
    };
});




  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

李秀才

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值