angular service

归属module (name, constructor)

提供一个服务

与factory 相似

var app = angular.module('myapp', []).value('testvalue', 'widuu').service('testservice',
function(testvalue) {
    this.lable = function() {
        return "this will output:hello " + testvalue;
    }
});
app.controller('mytest',
function($scope, testvalue, testservice) {
    $scope.test = "hello " + testvalue;
    $scope.output = testservice.lable();
});

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,477评论 19 139
  • "Unterminated string literal.": "未终止的字符串文本。", "Identifier...
    两个心阅读 12,655评论 0 4
  • 1、在android studio中安装checkstyle插件。 具体操作见上图。安装完之后见下图 底栏会多一个...
    nmssdmf阅读 9,065评论 0 4
  • 文章作者:Tyan博客:noahsnail.com 3.4 Dependencies A typical ente...
    SnailTyan阅读 9,750评论 2 7
  • AngularJS是什么?AngularJs(后面就简称ng了)是一个用于设计动态web应用的结构框架。首先,它是...
    200813阅读 5,563评论 0 3