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);
  • 相关阅读:
    CSS---伪类
    CSS---选择器
    CSS---如何引用样式表
    HTML-- 表单
    HTML-- 文本标签
    HTML--连接、锚点
    HTML--表格
    递归算法
    PHPCMS V9 友情链接的调用
    thinkcmf跳转用户登录和个人中心页面时出现Call to undefined function sp_sql_posts()错误
  • 原文地址:https://www.cnblogs.com/diydyq/p/4177353.html
Copyright © 2011-2022 走看看