AnjularJS初学(AnjularJS跨域取值)

来源:互联网 发布:mysql管理员招聘 编辑:程序博客网 时间:2024/05/22 20:20
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<script type="text/javascript" src="js/jquery-1.11.3.js"></script>
<script type="text/javascript" src="js/angular.js" ></script>
</head>
<body ng-controller="tellist" >
<div class="btn-group">
<p>活动名称:<input type="text" name="active_name"    ng-model="active_name"/></p>
<p>活动编号:<input type="tel"  name="active_number"  ng-model="active_number"/></p>
<p>活动时间:<input type="text" name="active_time"    ng-model="active_time"/></p>
<p>活动内容:<input type="text" name="active_content" ng-model="active_content"></p>
<p>活动状态:<input type="text" name="active_state"   ng-model="active_state"/></p>
<p><button class="btn-block" ng-click="submit_btn()">确定</button></p>
<p><button class="btn-block" ng-click="assign_btn()">赋值</button></p>
<p><button class="btn-block" ng-click="close_btn()">取消</button></p>
</div>
</body>
<script type="text/javascript">
var app=angular.module("app",[]);
app.constant("URL_sub",'http://192.168.21.176:8050/mbay-promotion-web/promotion/campaign/findBaseInfo/');
app.constant("URL_read",'')
app.controller("tellist",function($scope,URL_sub){
$scope.active_mess=[
{"active_name":"促销神器","active_number":"20150914111001","active_time":"2015-09-04","active_content":"促销神器","active_state":"已完结"},
{"active_name":"客户关怀","active_number":"20150914111002","active_time":"2015-09-01","active_content":"客户关怀","active_state":"已完结"}
];
$scope.active_name="";
$scope.active_number="";
$scope.active_time="";
$scope.active_content="";
$scope.active_state="";
$scope.submit_btn=function(){
alert($scope.active_name);
alert($scope.active_number);
alert($scope.active_time);
alert($scope.active_content);
alert($scope.active_state);
$http.get(URL_sub+$scope.active_name+"-"+$scope.active_number+"-"+$scope.active_time+"-"+$scope.active_content+"-"+$scope.active_state).success(function(data){
console.log(data);
}).error(function(data){
console.log(data);
});
}
$scope.assign_btn=function(){
$scope.active_name=$scope.active_mess[0].active_name;
$scope.active_number=$scope.active_mess[1].active_number;
$scope.active_time=$scope.active_mess[0].active_time;
$scope.active_content=$scope.active_mess[1].active_content;
$scope.active_state=$scope.active_mess[0].active_state;
}
$scope.close_btn=function(){
$scope.active_name="";
$scope.active_number="";
$scope.active_time="";
$scope.active_content="";
$scope.active_state="";
}
});


   $(function(){
    $('input').each(function(){ 
    var $val=$(this).val(); 
    $(this).focus(function(){
    if($(this).val()==$val){
    $(this).val("");
    }
    })
    $(this).blur(function(){
    if($(this).val().length==0){
    $(this).val($val)
    }
    })
    });
    })
</script>
</html>
1 0
原创粉丝点击