首页 \ 问答 \ 谷歌饼图切片通过变量传递值为偏移量(google pie chart slices pass value through variable for offset)

谷歌饼图切片通过变量传递值为偏移量(google pie chart slices pass value through variable for offset)

我正在使用谷歌图表api和angularjs.I需要通过变量设置切片值。所有示例我已经看到它们是硬编码或使用foreach循环。如何通过变量设置选定的饼图片值。这是我的代码?“selectedRow”变量作为字符串传递而不是作为变量传递。

        $scope.onSelectRowFunction = function(selectedItem)
        { 

           var selectedRow = parseInt(selectedItem.row);
           $scope.chartpie.options = {
                "slices": {selectedRow : {"offset": 0.4}},
                "title": "Title is here",
                "isStacked": "true",                    
                "sliceVisibilityThreshold": 0,
                "displayExactValues": true
           };


       };

I am using google chart api and angularjs.I need to set slices value through variable.All example i have seen they are hardcoded or using foreach loop.How could i set selected pie slice value through variable.Here is my code?"selectedRow" variable is passing as a string not as a variable.

        $scope.onSelectRowFunction = function(selectedItem)
        { 

           var selectedRow = parseInt(selectedItem.row);
           $scope.chartpie.options = {
                "slices": {selectedRow : {"offset": 0.4}},
                "title": "Title is here",
                "isStacked": "true",                    
                "sliceVisibilityThreshold": 0,
                "displayExactValues": true
           };


       };

原文:https://stackoverflow.com/questions/26764504
更新时间:2023-08-14 19:08

最满意答案

你可以这样做 :

$('a[href~="tel:{{telefono}}"]').attr('href', 'tel:'+telefono);

如果你想要更通用的东西,那就是你要在所有属性href替换{{telefono}} ,你可以使用:

$('[href~="{{telefono}}"]').attr('href', function(i, v) {
   return v.replace('{{telefono}}', telefono);
});

编辑:

如果您还想更改a元素的内容,可以执行以下操作:

$('[href~="{{telefono}}"]').attr('href', function(i, v) {
   return v.replace('{{telefono}}', telefono);
}).html(telefono);

You can do this :

$('a[href~="tel:{{telefono}}"]').attr('href', 'tel:'+telefono);

If you want something more generic, that is you want to replace {{telefono}} in all your attributes href, you could use this :

$('[href~="{{telefono}}"]').attr('href', function(i, v) {
   return v.replace('{{telefono}}', telefono);
});

EDIT :

If you also want to change the content of the a element, you can do this :

$('[href~="{{telefono}}"]').attr('href', function(i, v) {
   return v.replace('{{telefono}}', telefono);
}).html(telefono);

相关问答

更多
  • 这是我将如何检索href属性列表: var loader:URLLoader = new URLLoader(); var request:URLRequest = new URLRequest("xml/main.xml"); loader.addEventListener(IOErrorEvent.IO_ERROR, function errorHandler(event:IOErrorEvent):void { trace("Error loading XML" + event.type); ...
  • 最有可能的是,您看到的URL是浏览器作为最终URL所描述的内容......在源代码中,它最有可能是您想要的...... 在HTML中,hrefs如果不是以协议(http,ftp,mailto ..etc)开头的话,那么它们就会被作为相对URL地址。这意味着相对于当前网址的位置。 要么改变 或者 www.mysite.ru ...
  • 由于href具有特殊字符,因此需要包装属性值。 此外,.find()返回一个jQuery对象,无论是否找到匹配项,因此您需要检查jQuery对象是否包含任何元素 - 您可以检查该属性的长度属性 var navcur = window.location.href; $(".subnavli").each(function () { if ($(this).find("a[href='" + navcur + "']").length) { alert('works!'); } ...
  • 在保存图像的回调函数中重新加载图像: function capture() { $('#zoomTarget').html2canvas({ onrendered: function (canvas) { var url = "ajax.php"; var imgSrc = canvas.toDataURL(); $.post(url, {contentVar: imgSrc }, function(data) ...
  • 由于您选择的选择了id为#cartLink的任何元素,因此您可以在函数中将其称为$(this)。 在var url = ...之后; 写下面的内容: $(this).attr('href', url); http://api.jquery.com/attr/ Since your selected has selected any element with id #cartLink, you'll be able to refer to it as $(this) from within your fun ...
  • 主要编辑: 问题是在表单标签内的单个将提交表单,所以发生的是,输入输入,按Enter键,这会导致blor,因此onchange事件会触发,一切都会显示出来在调试器中很好。 完成后,页面重新加载(因为默认表单action是GET当前页面)而没有闪烁,重置输入值。 解决方案1:删除
    标记。 表单元素在此代码段中没有做任何有用的事情。 解决方案2:将onsubmit=return(false)属性添加到 。 解决方案3:向表单添加另一个非隐藏输入。 MAJOR EDIT: Th ...
  • 尝试这个: linktextx linktexty linktextz