小编Cap*_*gan的帖子

AngularJS ui-gmap-google-map删除行车路线

使用AngularJS和ui-gmap-google-map指令(http://angular-ui.github.io/angular-google-maps/#!/)我创建了一个谷歌地图,绘制了驱动路线.当我尝试绘制不同的路线时,第一条路线仍然在地图上.我试过directionsDisplay.setMap(null); 删除旧路由,但这不起作用.有人可以帮忙吗?

这是我的控制器代码的相关部分:

uiGmapIsReady.promise().then(function (map_instances) {
                $scope.mapRef = $scope.map.control.getGMap();
            });

$scope.getDirections = function (lat, long, origin, type) {
            uiGmapGoogleMapApi.then(function (maps) {
                var directionsService = new maps.DirectionsService();
                var directionsDisplay = new maps.DirectionsRenderer();

                if (origin == "" || type == "geo") {
                    origin = $scope.geoPosition.coords.latitude + ", " + $scope.geoPosition.coords.longitude;
                }

                var request = {
                    origin: origin,
                    destination: lat + ", " + long,
                    travelMode: maps.TravelMode['DRIVING'],
                    optimizeWaypoints: true
                };

                directionsService.route(request, function (response, status) {
                    if (status === google.maps.DirectionsStatus.OK) {
                        directionsDisplay.setMap(null); …
Run Code Online (Sandbox Code Playgroud)

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

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

格式化JSF电话号码

我将电话号码存储为数据库中的字符串.它将被存储为"1234567890".我想向用户显示它并将其格式化为(12)3456-7890如何使用JSF 2.0执行此操作?我尝试了以下,但它不起作用:

<h:outputText value="1234567890">
<f:convertNumber pattern="(##) ####-####"/>
</h:outputText>
Run Code Online (Sandbox Code Playgroud)

jsf

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

Angular 5 应用程序在 ios8(浏览器堆栈)中不起作用

我已经在运行 IOS8 (Safari) 的 iPhone 6 和 Browserstack 中测试了我的 Angular 5 应用程序。angular 应用程序没有运行,我只是得到一个空页面和这个 Javascript 错误。

有什么建议?

在此处输入图片说明

这是我的 package.json 文件。我认为我在此处添加的某些包导致了一些冲突并阻止了应用程序的显示。以前我的应用程序能够在 IOS8 中运行,但那是在 Angular 4.4 中运行的,我没有使用 mdbootstrap 库。

{
    "name": "XXXX",
    "version": "1.0.0",
    "license": "MIT",
    "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e",
        "i18n": "ng-xi18n"
    },
    "private": true,
    "dependencies": {
        "@agm/core": "^1.0.0-beta.2",
        "@angular-devkit/schematics": "0.0.34",
        "@angular/animations": "^5.0.3",
        "@angular/common": "^5.0.3",
        "@angular/compiler": "^5.0.3",
        "@angular/core": "^5.0.3",
        "@angular/forms": "^5.0.3",
        "@angular/http": "^5.0.3",
        "@angular/platform-browser": "^5.0.3",
        "@angular/platform-browser-dynamic": "^5.0.3",
        "@angular/router": …
Run Code Online (Sandbox Code Playgroud)

ios angular

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

AngularJS 显示分层数据

我正在尝试在分层视图中显示数据列表。我的数据看起来像这样:

items:[
  {
    "model_id": "1",
    "model_type_id": "1",
    "name": "Parent 1",
    "model_parent_id": ""
  },
  {
    "model_id": "2",
    "model_type_id": "1",
    "name": "Parent 2",
    "model_parent_id": ""
  },
  {
    "model_id": "3",
    "model_type_id": "2",
    "name": "Child 1",
    "model_parent_id": "1"
  },
  {
    "model_id": "4",
    "model_type_id": "2",
    "name": "Child 2",
    "model_parent_id": "2"
  }
]
Run Code Online (Sandbox Code Playgroud)

我的控制器看起来像:

myApp.controller('ModelController', ['$scope', 'ModelFactory',
    function ($scope, ModelFactory) {

        $scope.init = function (id) {
            $scope.brandId = id;
            getModels($scope.brandId);
        };

        function getModels(brandId) {

            ModelFactory.GetModels(brandId)
                .success(function (mdls) {
                    $scope.models = mdls;
                    console.log($scope.mdls);
                })
                .error(function (error) { …
Run Code Online (Sandbox Code Playgroud)

filtering angularjs

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

AngularJS 没有“Access-Control-Allow-Origin”标头

我有一个 AngularJS 应用程序,我需要将数据发布到第三方 URL,该 URL 用于在第三方服务器上存储一些数据。运行下面的代码时出现以下错误: XMLHttpRequest 无法加载http://thirdparty.url.com/。对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,不允许访问Origin ' http://localhost:51491 '。

我在我的 AngularJS 工厂中运行的代码是:

return $http({
            url: '//thirdparty.url.com',
            method: "POST",
            data: params_string,
            headers: {
                'Access-Control-Allow-Origin': '*',
                'Access-Control-Allow-Methods': 'POST, GET, OPTIONS, PUT',
                'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept'
            }
        });
Run Code Online (Sandbox Code Playgroud)

javascript cors angularjs

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

AngularJS ng-click无效

我正在使用AngularJS 1.4.2(使用Angular Material),我正在尝试实现一个保存功能.但是,我的按钮没有触发ng-click.这是我的HTML代码:

<div ng-controller="ModelEditController" class="col-lg-12 fontArial slide" ng-repeat="mdl in model">
    <md-content layout-padding>
            <form name="modelEditForm" novalidate role="form" unsaved-warning-form>
            <md-input-container flex style="width:100%">
                        <label>Name</label>
                        <input required name="model_name" ng-model="mdl.model_name" maxlength="100">
                </md-input-container>

        </form>
    </md-content>

    <div class="panel-footer footer" ng-controller="TestController">
        <md-button class="md-fab md-primary md-hue-2" aria-label="Save" ng-click="editModel(mdl)">
                    <md-icon md-svg-src="/img/icons/save.svg"></md-icon>
        </md-button>

    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

这是我的javascript代码:

var myApp = angular.module('myApp', ['ui.bootstrap', 'ui.router', 'ngCookies', 'ng-sortable', 'vAccordion', 'ngRoute', 'ngAnimate', 'fiestah.money', 'uiSwitch','ngMaterial','ngMessages','unsavedChanges'])
});


myApp.controller('TestController', ['$scope', 'ModelService', function ($scope,ModelService){

        function editModel(xMdl) {
            console.log("Inside edit model");

        }

    }]);
Run Code Online (Sandbox Code Playgroud)

"内部编辑模型"文本未输出到控制台.为什么ng-click不起作用?

javascript angularjs

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