angular.js - Beego 与 AngularJS的模板格式冲突,该怎么解决?
漂亮男人
漂亮男人 2017-05-15 16:49:08
0
5
969

我在 HTML 里使用了 ·angularjs· 的模板,但是在beego的 Controller 中,我设置

this.TplNames = "index.html"

但是运行之后服务器端报出的信息如下图:

我猜测是因为 beego 用 Go 自己的模板解析了,所以找不到变量。但是我把autorender=false也设置了之后,还是会显示这个错误,而且前端也收不到index.html的内容了。

漂亮男人
漂亮男人

reply all(5)
滿天的星座

https://github.com/astaxie/beego/issues/297 This has been answered by the author.

beego.TemplateLeft = "<<<" 
beego.TemplateRight = ">>>"
仅有的幸福

beego doesn’t understand
But if it’s a template conflict, just change Angular’s ​​template matching
For example:

app.config ($interpolateProvider) ->
  $interpolateProvider.startSymbol '//'
  $interpolateProvider.endSymbol '//'
小葫芦

If an error is reported on the server side, it must be an error when beego parses the template. Angular's template is pure HTML, because it is a front-end library, so if an error occurs, it will definitely be reported in the browser console. Where exactly something went wrong, you need to take out the code and analyze it for everyone.

習慣沉默

There is a Delims function in the template package, which may be what you need. It can change the identifier of the GO parsed template file

我想大声告诉你

The template syntax of golang is very close to the template syntax of angularJS, so it is easy to report errors. Here are two solutions.

  • Replace the angularJS template content in the homepage with the golang template tag, for example {{ user.name }} into {{ _user.name }}, and then use golang to render {{ _user.name }} into '{ { user.name }}'. This method can solve the problem, but it is cumbersome to teach.

  • Reduce the content on the homepage and try to include the corresponding routing template during design.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!