GVKun编程网logo

angularjs – 带有templateParameter属性的Angular google map window指令(angularjs指令的作用)

9

这篇文章主要围绕angularjs–带有templateParameter属性的Angulargooglemapwindow指令和angularjs指令的作用展开,旨在为您提供一份详细的参考资料。我们

这篇文章主要围绕angularjs – 带有templateParameter属性的Angular google map window指令angularjs指令的作用展开,旨在为您提供一份详细的参考资料。我们将全面介绍angularjs – 带有templateParameter属性的Angular google map window指令的优缺点,解答angularjs指令的作用的相关问题,同时也会为您带来AngularJs Understanding Angular Templates、AngularJS ng-bind-template 指令详解、AngularJs Understanding Angular Templates、angularjs – Angular $routeParams是空白的的实用方法。

本文目录一览:

angularjs – 带有templateParameter属性的Angular google map window指令(angularjs指令的作用)

angularjs – 带有templateParameter属性的Angular google map window指令(angularjs指令的作用)

我正在使用 Angular-google-map库来显示带有这样的窗口的标记:

<google-map center="map.center"
 zoom="map.zoom"
 draggable="true"
  bounds="" 
   options ="{styles:map.options}"
  >

    <marker ng-repeat="hotel in hotelsFiltered"
     idKey="hotel.id"
     coords="{latitude:hotel.latitude,longitude:hotel.longitude}"
     hoteldata="hotel"
     icon="icon">
    </marker>

    <window ng-repeat="hotel in hotelsFiltered"
     coords="{latitude:hotel.latitude,longitude:hotel.longitude}"
     templateUrl="hotel.templateUrl"
     templateParameter="{title:'myTitle'}"
     show="hotel.show"
    >

    </window>


</google-map>

所以在window指令中我提供了templateUrl,并且标记成功显示了信息窗口,但问题是我在templateParameter中提供的参数似乎无法在模板视图中访问.
这是我的infoWindow的模板视图以及我如何尝试从window指令访问传递的参数:

<div>
 {{title}}
 the title was not showed successfully 
</div>

解决方法

我有一个非常类似的问题,解决方案是更新模板中的绑定,如下所示:

<div>
   {{parameter.title}}
</div>

其余代码可以保持不变.

AngularJs  Understanding Angular Templates

AngularJs Understanding Angular Templates

  angular template是一个声明规范,与model、controller的信息一起,渲染成用户在浏览器中所看到的视图。它是静态的DOM,包括HTML、CSS、angular特别的元素和angular指定的元素属性。angular元素和属性指示angular去扩展行为以及将template DOM转换为动态视图的DOM。

  下面是我们可以在template中使用的angular元素已经元素属性的类型:

  1. Directive(https://www.jb51.net/article/91739.htm) - 一个扩展现有DOM元素或者代表一个可复用的DOM组件的属性或者元素,即控件。
  2. Markup(http://code.angularjs.org/1.0.2/docs/api/ng.$interpolate) - 通过双大括号表示法{{}}来绑定表达式到元素中,是内建的angular标记。
  3. Filter(http://code.angularjs.org/1.0.2/docs/guide/dev_guide.templates.filters)- 用于格式化我们给用户看的数据。
  4. Form controls (https://www.jb51.net/article/91744.htm)- 让我们验证用户输入。

  注意:除了可以在模版中声明上面的元素以外,我们也可以在javascript代码中访问这些元素。

  下面的代码片段,展示了一个简单的angular template,它由标准的HTML标签以及angular directive、花括号绑定的expression({{expression}},https://www.jb51.net/article/91742.htm)组成。

<!DOCTYPE html>
<!--ng-app,定义应用范围,在这里创建root scop-->
<html ng-app>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 <title>template</title>
 <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
 <style type="text/css">
 .ng-cloak {
  display: none;
 }
 </style>
</head>
<!--
 ng-cloak,在编译后会去掉的class
 ng-controller,一个directive,用于指定当前的模版对应的Controller为MyController
-->
<bodyng-controller="MyController">

<!--
 ng-model,directive,用于指定input的值对应的model为foo。
-->
<input type="text" ng-model="foo" value=""/>
<!--
 ng-click,directive,单击后需要做的事情,可以是expression,如 buttonText = ''1'';
 也可以是调用函数,如下面所示。
 {{buttonText}},用于展示当前scope链中能够或得到的buttonText的值
-->
<button ng-click="changeFoo()">{{buttonText}}</button>

<script src="../angular-1.0.1.js" type="text/javascript"></script>
<script type="text/javascript">
 function MyController($scope) {
 $scope.buttonText = "默认的东东";//初始化model buttonText
 $scope.foo = "修改我吧";//初始化model foo
 $scope.changeFoo = function() {//声明changeFoo
  this.buttonText = this.foo;//将foo的值赋给buttonText
  //这里使用的this,就是指向当前$scope的。
 };
 }
</script>
</body>
</html>


  在一个简单的单页应用中,模版由HTML、CSS以及angular directive组成,都包含在一个HTML文件中(通常叫它index.html)。但在一些更加复杂的应用中,我们可以在一个页面中,通过使用“partials”来显示多个视图,即将模版分段存放在独立的HTML文件中。我们可以在主页面中使用$route服务(http://code.angularjs.org/1.0.2/docs/api/ng.$route)与ngView directive(http://code.angularjs.org/1.0.2/docs/api/ng.directive:ngView)来协同“include”那些partials。这个技术的一个例子,展示在angular tutorial(http://code.angularjs.org/1.0.2/docs/tutorial/index)的第七、八步骤中。(这部分我稍后再玩-_-!)

以上就是对 AngularJs Understanding Angular Templates的资料整理,后续继续补充相关资料,谢谢大家对本站的支持!

您可能感兴趣的文章:
  • Springboot读取templates文件html代码实例
  • 深入浅析springboot中static和templates区别
  • SpringBoot中关于static和templates的注意事项以及webjars的配置
  • SpringBoot用JdbcTemplates访问Mysql实例代码
  • 详解Python的Django框架中的templates设置
  • asp.net使用jquery模板引擎jtemplates呈现表格
  • Blitz templates 最快的PHP模板引擎
  • Springboot访问templates html页面过程详解

AngularJS ng-bind-template 指令详解

AngularJS ng-bind-template 指令详解

AngularJS ng-bind-template 指令

AngularJS 实例

<p> 元素上绑定两个表达式:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>

<div ng-app="myApp" ng-bind-template="{{firstName}} {{lastName}}" ng-controller="myCtrl">

</div>

<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
 $scope.firstName = "John";
 $scope.lastName = "Doe";
});
</script>

</body>
</html>

运行结果:

         John Doe

定义和用法

ng-bind-template 指令用于告诉 AngularJS 将给定表达式的值替换 HTML 元素的内容。

当你想在 HTML 元素上绑定多个表达式时可以使用 ng-bind-template 指令。

语法

<element ng-bind-template="expression"></element>

所有的 HTML 元素都支持该指令。

参数值

描述
expression 一个或多个要执行的表达式,每个使用 {{  }} 包含。

以上就是对 AngularJS ng-bind-template 指令知识介绍,有需要的朋友看下。

您可能感兴趣的文章:
  • 深入理解AngularJS中的ng-bind-html指令
  • 深入理解AngularJS中的ng-bind-html指令和$sce服务
  • AngularJS ng-bind-html 指令详解及实例代码
  • AngularJS ng-bind 指令简单实现
  • ANGULARJS中用NG-BIND指令实现单向绑定的例子
  • AngularJS基础 ng-model 指令详解及示例代码
  • Angular.js回顾ng-app和ng-model使用技巧
  • angularjs在ng-repeat中使用ng-model遇到的问题
  • Angular中ng-bind和ng-model的区别实例详解

AngularJs Understanding Angular Templates

AngularJs Understanding Angular Templates

  angular template是一个声明规范,与model、controller的信息一起,渲染成用户在浏览器中所看到的视图。它是静态的DOM,包括HTML、CSS、angular特别的元素和angular指定的元素属性。angular元素和属性指示angular去扩展行为以及将template DOM转换为动态视图的DOM。

  下面是我们可以在template中使用的angular元素已经元素属性的类型:

  1. Directive() - 一个扩展现有DOM元素或者代表一个可复用的DOM组件的属性或者元素,即控件。
  2. Markup(http://code.angularjs.org/1.0.2/docs/api/ng.$interpolate) - 通过双大括号表示法{{}}来绑定表达式到元素中,是内建的angular标记。
  3. Filter(http://code.angularjs.org/1.0.2/docs/guide/dev_guide.templates.filters)- 用于格式化我们给用户看的数据。
  4. Form controls ()- 让我们验证用户输入。

  注意:除了可以在模版中声明上面的元素以外,我们也可以在javascript代码中访问这些元素。

  下面的代码片段,展示了一个简单的angular template,它由标准的HTML标签以及angular directive、花括号绑定的expression({{expression}},)组成。

rush:js;"> <Meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> template <Meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">