• part 2 Angular modules and controllers


    What is a module in AngularJS?

    A module is a container for different parts of your application i.e controllers,services,directives,filters,etc.

    You can think of a module as a Main() method in other types of applications.

    How to create a module?

    Use the angular object's module() method to create a module.

    var myApp = angular.module("myModule",[]);//the first parameter specify the name of module,the second parameter specify the dependence for the module,here i just set an empty array. 

    What is a controller in angular?

    In angular a controller is a JavaScript function. The job of the controller is to build a model for the view to display.

    How to create a controller in angular?

    var myController = function($scope){
        $scope.message="AngularJS Tutorial";    
    };

    How to register the controller with the module?

    myApp.controller("myController",myController);           //  1 way
    myApp.controller("myController",function($scope){       // 2 way
        $scope.message="AngularJS Tutorial";    
    });

    In js file , we can add a reference with angular.js to has some code tip.(autocomplete some angular member.)

  • 相关阅读:
    word2vec模型评估方案
    分词问题整理和发现
    11.1第一次相似度算法测试结果
    如何使用向量代表文档doc或者句子sentence
    fasttext学习笔记
    传统变量抽样
    统计抽样与非统计抽样
    误受风险和误拒风险
    企业所得税怎么算
    进一步审计程序
  • 原文地址:https://www.cnblogs.com/gester/p/5031573.html
Copyright © 2020-2023  润新知