小编Che*_*Lin的帖子

Angular-Google-Map:如何在加载位置数据后加载地图(Lat,Lng)?

我收到了错误:'angular-google-maps:找不到有效的中心属性'.当我看到我的locationData从php后端和exec初始化函数加载.

HTML:

<div ng-init="locationData = '<?=htmlspecialchars($data)?>'">
    <google-map center="map.center" zoom="map.zoom" options="map.options"></google-map>
</div>
Run Code Online (Sandbox Code Playgroud)

角度控制器:

app.controller('MapCtrl', ['$scope', function ($scope) {
    'use strict';

    $scope.$watch('locationData', function() {
        var location = JSON.parse($scope.locationData);
        $scope.location = {
            lng : location.longitude,
            lat : location.latitude
        initialize();
    });

    function initialize() {
        var mapOptions = {
            panControl    : true,
            zoomControl   : true,
            scaleControl  : true,
            mapTypeControl: true,
            mapTypeId     : google.maps.MapTypeId.ROADMAP
        };

        $scope.map = {
            center: {
                latitude: $scope.location.lat,
                longitude: $scope.location.lng
            },
            zoom: 13,
            options: mapOptions,
        };
    }
}]);
Run Code Online (Sandbox Code Playgroud)

并且,我将$ scope.map设置移动到控制器块的顶部,并将常量值设置为map

center: { …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps google-maps-api-3 angularjs angular-google-maps

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

在AngularJS中实例化和初始化控制器

我有一个问题是使用Angular实现控制器.我有一个主控制器AlkeTypeDefListController,我想从中动态创建/删除AlkeTypeDefController类型的控制器,所以我做到了:

AlkeTypeDefListController的代码:

//  Create main controller          
Alke.controller('AlkeTypeDefListController', ['$scope', '$controller', function($scope, $controller)
{
    var primitives = 
    [

    ];

    //  Add some properties to the scope
    angular.extend($scope,
    {
        typedefs        : primitives,
        addTypeDef      : function()
        {            
            var controller = $controller("AlkeTypeDefController", {$scope:$scope.$new()});
            $scope.typedefs.push(controller);
        }             
    });   
}]);
Run Code Online (Sandbox Code Playgroud)

AlkeTypeDefController的代码:

//  Create main controller          
Alke.controller('AlkeTypeDefController', ['$scope', '$controller', function($scope, $controller)
{
    //  Add some properties to the scope
    angular.extend($scope,
    {
        name            : "New Type",
        fields          : [],
        addField        : function() …
Run Code Online (Sandbox Code Playgroud)

javascript controller angularjs

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

量角器E2E测试错误:对象[对象]没有方法'getWindowHandle'

我试图点击按钮检查弹出的Facebook登录开放.

Error : Object [object Object] has no method 'getWindowHandle'.
Run Code Online (Sandbox Code Playgroud)

代码段生成错误:

describe('Tests', function() {
  var ptor;
  var handlePromise;
  var util = require('util');

  beforeEach(function() {
    ptor = protractor.getInstance();
    handlePromise = ptor.getAllWindowHandles();
    var handlesDone = false;
    ptor.get('/SiteB_Upgrade_Device/app/index.html#/Recommendations#page');
    ptor.findElement(by.id('fb')).click();
    ptor.ignoreSynchronization = true;
  });

  describe('login', function() {
    return it('should switch to popUp\'s handle', function() {
      handlePromise.then(function(handles) {
        var popUpHandle = handles[0];
        var handle = browser.driver.switchTo().window(popUpHandle).getWindowHandle();
        expect(handle).toEqual(popUpHandle);
      });
    },30000);
  });
});
Run Code Online (Sandbox Code Playgroud)

javascript jasmine angularjs selenium-webdriver protractor

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

Angularjs +如何在指令中获取先前的输入字段值

我有一个表格,其中有2个日期字段,来自datetodate.我正在编写一个指令来比较这个日期字段.

如何把从日期filed.I正在调用的是我的自定义指令onBlurtoDate,现在需要采取fromdate.The的外形设计为fillows.

<div class="row">
  <div class="col-xs-6 col-sm-6 col-6">
    <label>From date</label>
    <input type="text" id="eduFromDate" name="eduFromDate" class="form-control" 
           ng-model="education.fromDate" ui-date/>
  </div>
  <div class="col-xs-6 col-sm-6 col-6">
    <label>To date</label>
    <input type="text" name="edutoDate" class="form-control" id="edutoDate" 
           ng-model="education.toDate" ui-date before-date/>
    <span class="error input-icon fui-alert" 
          ng-show="historyForm.edutoDate.$error.beforeDate"></span>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angularjs-directive

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

onApprove和onDeny没有在模态 - 语义ui中触发

当我显示我的模态时,会自动调用onApprove事件.我怎么能阻止这个?我的代码如下

<div class="item">
    <div class="content">
       <a href="#" ng-click="showItemPanel()">Deactivate Account</a>
       <div id='showItemModal' class='ui modal'>
       <i class="close icon"></i>
       <div class="header">
         Deactivate User
       </div>
       <div class="content">
       <form class="ui form" name="ItemModalForm">
          <div class="field">
            You want to go to shopping?                 
          </div>
       </form>
       </div>
       <div class="actions">
        <div class="ui tiny button">Cancel</div>
        <div class="ui tiny green button" ng-click="showItems()">De-Activate</div>
        </div>
       </div>
   </div>
Run Code Online (Sandbox Code Playgroud)

controller.js

$scope.showItemPanel= function() {
            var modalElem= $('#showItemModal').modal('setting', {
            closable  : false,
            onDeny    : function(){
              window.alert('Wait not yet!');
              return false;
            },
            onApprove : itemPanelOpen()
            });
          modalElem.modal('show');           
        }
        function …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs semantics

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

如何从angularjs中的控制器调用Ui-Bootstrap 0.10.0中的$ modal.open

如何$modal.open从角度js中的控制器调用.以前在ui-bootstrap中有0.1.0对话框.现在在当前版本中,调用对话框的权限是什么.

在0.1.0中它只是$ dialog.dialog(); 然后调用Dialog(); 在Lib -

return {
  // Creates a new `Dialog` with the specified options.
   dialog: function(opts){
      return new Dialog(opts);
},

// creates a new `Dialog` tied to the default message box template and controller.
//
// Arguments `title` and `message` are rendered in the modal header and body sections respectively.
// The `buttons` array holds an object with the following members for each button to include in the

// modal footer section:

// * `result`: …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angular-ui angular-ui-bootstrap

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

如何抑制警告"gets()已被弃用"?

每当我尝试使用gets()函数输入我的字符串时,我的编译器会给出警告,如下所示.如何摆脱这个.我究竟做错了什么?

test.c:27:2: warning: ‘gets’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
gets(temp);
^
Run Code Online (Sandbox Code Playgroud)

gcc compiler-warnings suppress-warnings

4
推荐指数
1
解决办法
3万
查看次数

Browserify - bower vs npm节点模块

我真的不知道bower_components目录来自我的Node Express应用程序,但它似乎与我的node_modules文件夹竞争关注,因为它们包含jquerybootstrap.

我正在使用Browserify,我正在尝试捆绑jquery,bootstrap和其他一些组件.Bower到底发生了什么?我需要鲍尔吗?

例如,当我require('jquery')在我的应用程序代码中执行操作时,如何知道它是来自NPM node_modules还是Bower bower_components?

node.js npm twitter-bootstrap browserify bower

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

window.opener | 没有使用chrome

我有两个html页面..我正在从孩子那里调用父窗口.所有的东西都很棒.但是在Chrome中它失败了..我知道原因..

test1.html: -

<html>
<head>
<title>Compose</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<SCRIPT>
function test(){
//alert('');
var win = window.open('../login/test2.html',"","height=700,width=800");
}
function test1(){
alert('test1');
}
</SCRIPT>
</head>
<body>

<input type="button" value="click" onclick="test();" />             
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

test2.html: -

<html>
<head>
<title></title>
<SCRIPT>
function opener1(){
try{
    if(window.opener != null && !window.opener.closed)
    {

    }
    window.opener.test1();
    }catch(e){ alert(e.description);}
}
</SCRIPT>
</head>
<body oncontextmenu="return false"  ondragstart="return false" onload="opener1();">
<h1>Test Page</h1>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

来自test2.html的test1.html中的调用方法无法正常工作..任何解决方案......都认可.谢谢

html javascript google-chrome

3
推荐指数
1
解决办法
2万
查看次数

Angularjs选择指令,$摘要问题

我在指令中使用了一个名为selectize的第三方插件时遇到了麻烦.

我已经阅读了很多关于$ digest/$ watch的内容,但我仍然遇到问题.

我下面的例子"有效",但我正在努力防止$digest already in progress错误.

可能有更好的方法来解决这个问题,我不知道怎么做.

plunker:http://plnkr.co/edit/3JjTsEU2BlxPWHtw6HaW?p=preview

app.directive('selectize', function($parse) {
return {
  restrict: 'A',
  require: ['ngModel'],
  scope: {
    ngModel: '=',
    options: '='
  },
  link: function(scope, el, attrs) {

    var $select = el.selectize({
      valueField: 'id',
      labelField: 'name'
    });

    var selectize = $select[0].selectize;

    // add options
    angular.forEach('options', function(tag) {
      selectize.addOption(tag);
    });

    scope.$watchCollection('options', function(newTags, oldTags) {

      // why are these the same objects?
      console.log('newTags', newTags);
      console.log('oldTags', oldTags);

      if (newTags !== oldTags) {
        // clear …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angularjs-directive selectize.js

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