前端代码4.3.1 拷贝资源
将下列资源拷贝至 pinyougou-search-web
将 angularJS 拷贝到插件文件夹拷贝 base.js 到 js 文件夹
4.3.1 服务层
pinyougou-search-web 工程创建 searchService.js
//搜索服务层app.service("searchService",function($http){
this.search=function(searchMap){
return $http.post('itemsearch/search.do',searchMap);
}
});
4.3.1 控制层
pinyougou-search-web 工程 searchController.js
app.controller('searchController',function($scope,searchService){
//搜索
$scope.search=function(){
searchService.search( $scope.searchMap ).success(
function(response){
$scope.resultMap=response;//搜索返回的结果
}
);
}
});
4.3.1 页面
pinyougou-search-web 工程 search.html引入 js
<script type="text/javascript" src="plugins/angularjs/angular.min.js"> </script>
<script type="text/javascript" src="js/base.js"> </script>
<script type="text/javascript" src="js/service/searchService.js"> </script>
<script type="text/javascript" src="js/controller/searchController.js"> </script>
指定控制器
<body ng-app="pinyougou" ng-controller="searchController">
绑定搜索框
</strong>
</div>
<div class="attr">
<em>{{item.title}}</em>
</div>
<div class="cu">
<em><span>促</span>满一件可参加超值换购</em>
</div>
<div class="commit">
<i class="command">已有 2000 人评价</i>
</div>
<div class="operate">
<a href="success-cart.html" target="_blank" class="sui-btn btn-bordered btn-danger">加入购物车</a>
<a href="javascript:void(0);" class="sui-btn btn-bordered">对比</a>
<a href="javascript:void(0);" class="sui-btn btn-bordered">关注</a>
</div>
</div>
</li>
转载于:https://blog.51cto.com/13517854/2176157