小编Cha*_*ies的帖子

AngularJS中的指令在加载时触发$ watch回调函数

我有以下指令:

  leafletDirective = angular.module("leaflet-directive", [])
  leafletDirective.directive "leaflet", ($http, $log)  ->
    restrict: "E"
    replace: true
    transclude: true
    template: "<div id=\"map\"></div>"
    scope:
      origin: "=origin"
      points: "=points"
      shape: "=shape"
      clearmarkers: "=clearmarkers"
      markers: "=markers"
    link: (scope, element, attrs, ctrl) ->

      scope.origin = [40.094882122321145, -3.8232421874999996]
      scope.points = []
      scope.shape = []
      #create a CloudMade tile layer and add it to the map
      @map = L.map(attrs.id,
                  center: scope.origin
                  zoom: 5
      )
      L.tileLayer("http://{s}.tile.cloudmade.com/57cbb6ca8cac418dbb1a402586df4528/997/256/{z}/{x}/{y}.png",
                maxZoom: 18
      ).addTo @map


      #add markers dynamically
      updateMarkers = (pts) =>
        console.log "loading markers" …
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-directive

2
推荐指数
2
解决办法
3258
查看次数

剥离导轨仅用于api

我有一个应用程序,我们只是用于为其他应用程序提供api调用.然而,它仍然使用整个轨道感觉很重,但我们不使用视图等...

其他人如何解决这个问题,只是删除文件?我需要的只是我的模块和服务能力.

使用Sinatra会更好吗?

ruby api ruby-on-rails

1
推荐指数
1
解决办法
1041
查看次数

Angular app不会加载(JSFiddle)

我这里有一个简单的角度应用程序

<div ng-app="WhereToMeet" ng-controller="MapCtrl">
  <leaflet shape="shape"></leaflet>
  <button ng-click="clicked()">Clicked</button>
</div>


app = angular.module("WhereToMeet", [])

app.directive "leaflet",  ->
  restrict: "E"
  replace: true
  transclude: true
  template: "<div id=\"map\"></div>"
  scope:
    shape: "=shape"
  link: (scope, element, attrs, ctrl) ->
    scope.$watch attrs.shape,( (newValue, oldValue) ->
      watched newValue
    ), true

  watched = (newValue) ->
    alert newValue


@MapCtrl = ($scope)  ->
  clicked = (clicked) ->
    $scope.shape = "Clicked"
    alert "clicked"
Run Code Online (Sandbox Code Playgroud)

我有一个JSFiddle http://jsfiddle.net/charliedavi/bezFB/22/但它不会运行.真奇怪.我认为这是我的咖啡脚本的错误,但我看不到它

错误:

Uncaught SyntaxError: Unexpected string fiddle.jshell.net:22
Uncaught Error: No module: WhereToMeet 
Run Code Online (Sandbox Code Playgroud)

在纯JS中

var app;

app …
Run Code Online (Sandbox Code Playgroud)

coffeescript angularjs

1
推荐指数
1
解决办法
1043
查看次数

Ruby数组 - 最高整数

Ruby的全新品牌,热爱它.只是玩下面的代码:

    public
    def highest 
      highest_number = 0
      each do |number|
        number = number.to_i
        highest_number = number if number > highest_number
        puts highest_number 
      end
    end


    array = %w{1 2 4 5 3 8 22 929 1000 2}
    array.highest
Run Code Online (Sandbox Code Playgroud)

所以目前我得到的回应是:

    1
    2
    4
    5
    5
    8
    22
    929
    1000
    1000
Run Code Online (Sandbox Code Playgroud)

所以它首先放置数组,然后放入数组中的最高数字.但是我想要的只是最高的数字......

我玩过这个,无法搞清楚!对不起,这个新手问题

ruby arrays each

0
推荐指数
2
解决办法
373
查看次数

使用 grep 查找以字符开头且后面带有数字的字符串

好的,我有一个包含这样的数字的文件:

L21479
Run Code Online (Sandbox Code Playgroud)

我想做的是使用 grep (或类似的工具)来查找文件中具有以下格式的所有字符串:

L#####
Run Code Online (Sandbox Code Playgroud)

# 将是数字。SO 一个 L 后跟 5 个数字。

这在 grep 中可能吗?我应该加载文件并执行正则表达式吗?

grep

0
推荐指数
1
解决办法
5116
查看次数