2013-07-16 37 views
0

我一直在看这个例子,并期待通过谷歌无济于事。我不明白popover-template是如何工作的。它是Angular的模板系统吗?我找不到任何文件,所以我想我会转向社区。我该如何创建自己的模板?模板如何在Angular.js中工作?

<!DOCTYPE html> 
<html ng-app="myApp"> 

<head> 
    <script data-require="[email protected]" data-semver="1.1.5" src="http://code.angularjs.org/1.1.5/angular.min.js"></script> 
    <script data-require="[email protected]" data-semver="1.1.5" src="bootstrap-ui.js"></script> 
    <link data-require="[email protected]" data-semver="2.3.2" rel="stylesheet" href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" /> 
    <link rel="stylesheet" href="style.css" /> 
    <script src="script.js"></script> 
</head> 

<body ng-controller="Ctrl"> 
    <div style="padding-bottom: 400px"></div> 
    <div class="container-fluid"> 
    <fieldset> 
    <div class="control-group"> 
    <label class="control-label" for="tc">Sample:</label> 
     <div class="controls"> 
     <div class="input-prepend"> 
     <input placeholder="Enter end date.." type="text" class="input-small" ng-model="entity.endDate" name="endDate" /> 
     <button type="button" class="btn" ng-model="$parent.entity.endDate" popover-template="datepicker-test.html"> 
     <i class="icon-calendar"></i> 
     </button> 
    </div> 
    </div> 
    </div> 
    </fieldset> 
</div> 
</body> 
</html> 

回答

2

距离角UI的自举子项目directive

<button type="button" class="btn" ng-model="$parent.entity.endDate" popover-template="datepicker-test.html"> 

相应的JavaScript是inbootstrap-ui.js:

.directive('popoverTemplate', [ '$tooltip', function ($tooltip) { 
    return $tooltip('popoverTemplate', 'popover', 'click'); 
}]); 

该项目是在这里:https://github.com/angular-ui/bootstrap

+0

理智恢复。 – Strawberry

+0

Maarten,我有点困惑......我无法在[ui-boostrap](http://angular-ui.github.io/bootstrap/)代码中找到popoverTemplate指令......但奇怪的是这个[链接](http://embed.plnkr.co/Zxm90d/preview),它似乎使用相同的版本,但与该指令!...为什么? – wilver

+0

好的。我认为这是[answer](https://github.com/angular-ui/bootstrap/pull/1391#issuecomment-32494143):暂时的解决方法,而官方功能不可用... – wilver