Angularjs $ interpolate提供程序无法正常工作 [英] Angularjs $interpolate provider not working

查看:49
本文介绍了Angularjs $ interpolate提供程序无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使经过一些彻底的研究,我似乎也无法找到为什么我的$ interpolateProvider无效。这是我定义新符号的地方。

Even after some thorough research, i can't seem to find why my $interpolateProvider is not working. Here is where I define my new symbol.

var APP = APP || {};
APP.Subapp = APP.Subapp || {};
APP.Subapp.Admin = angular.module('APP.Subapp.Admin', ['APP.Subapp.Modules']);  
APP.Subapp.Admin.config(function($interpolateProvider) {
    $interpolateProvider.startSymbol('{[{').endSymbol('}]}');
});

我用ng-app调用正确的应用程序。

I do call the proper app with ng-app.

<html ng-app="APP.Subapp.Admin" ng-controller="MainController">
<head>
    <link rel="stylesheet" href="/stylesheets/style.css"/>
    ...

因为我正在使用车把我真的想改变它而我不能使用ng-bind,因为我需要通过某些函数传递信息,如ng-click。

Since I'm using handlebars I really want to change that and I can't use ng-bind because I need to pass information through some functions like an ng-click.

... ng-click="confirm({{client.id}}) ...

任何帮助都是非常感谢。

Any help would be greatly appreciated.

编辑//

我解决了我的问题,如果它可以帮助一些人在那里。好像我在主模块js文件中覆盖了我的配置。这是有效的代码。

I solved my problem, if it can help some people out there. It seems like i was overwriting my config in my main module js file. Here is the code that works.

(function(APP){
    'use strict';
     APP.Subapp.Admin.config(function( $controllerProvider, $interpolateProvider ){      
        APP.Subapp.Admin.controller = $controllerProvider.register;
        $interpolateProvider.startSymbol('{[{');
        $interpolateProvider.endSymbol('}]}');
    });
})(APP);


推荐答案

var customInterpolationApp = angular.module('customInterpolationApp', []);
  customInterpolationApp.config(function($interpolateProvider) {
    $interpolateProvider.startSymbol('[{');
    $interpolateProvider.endSymbol('}]');
  });
  customInterpolationApp.controller('DemoController', function() {
      this.label = "This binding by [{ }] interpolation symbols.";
  });

<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>custom-interpolation-markup-production</title>
  <script src="//code.angularjs.org/snapshot/angular.min.js"></script>  
</head>
<body ng-app="customInterpolationApp">
  
<div ng-controller="DemoController as demo">
    [{demo.label}]
</div>
</body>
</html>

我认为这会有所帮助。请试试。

I think this will help.Just try .

这篇关于Angularjs $ interpolate提供程序无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆