Giter Club home page Giter Club logo

Comments (2)

mcasimir avatar mcasimir commented on September 28, 2024

yieldTo content is saved as a string in a variable and re-appended to its container as default each time a route changes thus it is compiled with $compile just like the contentFor content.

So the same would happen with an empty contentFor.

Now the problem is that $compile implicitly passes strings to angular.element in order to convert it to a new dom element. If the string doesn't start with an html tag it assumes that is an attempt to use a jquery selector thus raising an error for the unsupported feature.

This is the code where the issue happens:

setContentFor: (name, content, scope) ->
    b = yielders[name]
    return unless b
    sanitizedContent = content.replace(/^\s+/, "")
    compiled = $compile( sanitizedContent )(scope)
    b.element.empty().append(compiled)

A quick fix could be to check if sanitizedContent is empty and just empty yield-to accordingly. But it would not work with another string. The following would also raise an error:

 <div class="navbar-brand navbar-brand-center" yield-to="title">
   The title
 </div>

So for now you can include an empty span if its not a problem.

 <div class="navbar-brand navbar-brand-center" yield-to="title">
   <span></span>
 </div>

I wish to figure out a better and more generic workaround, do you know a better way to overcome this problem?

from mobile-angular-ui.

mcasimir avatar mcasimir commented on September 28, 2024

Ok I found the right way to do that in the ngInclude source:

    b.element.html(content)
    $compile(b.element.contents())(scope)

Just released 1.0.7-beta fixing this issue.

Thank you

from mobile-angular-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.