zoukankan      html  css  js  c++  java
  • JS篇 AngularJS <<The complete guide of AngularJS>>笔记

    指令:

    angular.module('myApp', [])
    .directive('myDirective', function() {
        return {
            restrict: 'A',
         // 定义一个isolated scope
    scope: {} }; }) .directive(
    'myInheritScopeDirective', function() { return { restrict: 'A',
         // 新的子scope继承parent scope scope:
    true }; })
    .directive('myInheritScopeDirective', function() {
        return {
            restrict: 'A',
         // 使用指令元素节点上用其他指令(如:ng-controller)定义的scope scope: false }; })
     

     ng-init: 在当前DOM节点所属的scope上操作,最外层的scope为:$rootScope。

    定义服务的多种方式:

    // factory方式
    angular.module('myApp', []).factory('UserService', function($http) { var current_user; return { getCurrentUser: function() { return current_user; }, setCurrentUser: function(user) { current_user = user; } } });
    // service: contructor方式
    var Person = function($http) {
        this.getName = function() {
            return $http({
                method: 'GET',
                url: '/api/user'
            });
        };
    };
    angular.service('personService', Person);
  • 相关阅读:
    LCD编程_显示文字
    LCD编程_画点线圆
    LCD编程_简单测试
    LCD编程框架组织
    LCD编程_LCD控制器
    编程——抽象出重要的结构体
    LCD裸板编程_框架
    S3C2440_LCD控制器
    关于加密与解密的问题。
    [13期]mysql-root全手工注入写马实例实战
  • 原文地址:https://www.cnblogs.com/diydyq/p/4177353.html
Copyright © 2011-2022 走看看