zoukankan      html  css  js  c++  java
  • angular1.x 组件开发

    搜索框组件开发:

    1.注册组件

    app.js

    angular.module("myApp",[])
    .component("nameSearch",{
      templateUrl:"../components/nameSearch.html",
      template: "",
      controller:function ($scope,$rootScope) {
        // 搜索框内容
        $scope.searchContent = '';
        // 点击搜索操作
        $scope.query = function(val) {
          // 广播
          $rootScope.$broadcast("searchContent.updated", val);
        }
      }
    });

    2.创建组件

    components/nameSearch.html

    <!-- 姓名模糊查询组件(搜索框) -->
    <div class="bar bar-header item-input-inset">
      <label class="item-input-wrapper">
        <i class="icon ion-ios-search placeholder-icon"></i>
        <input ng-model="searchContent" type="search" placeholder="请输入矫正人员姓名">
      </label>
      <button ng-click="query(searchContent)" class="button button-positive">搜索</button>
    </div>
    
    <style>
      .item-input-inset{
        /**/
      }
    </style>

    3.父页面调用

    templates/tab-alarm.html

    <ion-view hide-nav-bar="true">
      <ion-content>
        <!-- 搜索框 -->
        <name-search></name-search>
      </ion-content>
    </ion-view>

    4.父页面接收 组件传参

    .controller('AlarmCtrl', ['$scope',function($scope) {
      /**
       * 获取搜索框内容
       */
      $scope.$on("searchContent.updated", function(event, data){
        console.log(data);
      });
    }])

    5.效果图

  • 相关阅读:
    运行jar包读取外部配置文件
    DES加密
    BlockingQueue
    文件锁
    Hive 的 排序
    linux下date命令实现时间戳与日期的转换
    bcov进行覆盖率统计
    对c++服务端进行覆盖率统计
    github基础命令
    gcc编译参数-fPIC问题 `a local symbol' can not be used when making a shared object;
  • 原文地址:https://www.cnblogs.com/crazycode2/p/9109162.html
Copyright © 2011-2022 走看看